Table of contents
Open Table of contents
Article body
When a browser sends a URL request to a server, each non-ASCII byte is converted to the form %xy. In UTF-8, a Chinese character is encoded as three bytes.
Before sending the data, the browser encodes the URL by calling URLEncoder.encode in java.net, as shown below.

As before, it calls Charset. This time, the encoding is obtained through Charset.forName(). If you step into that method, you’ll see that it is simply a wrapper around Charset.lookup(), as shown below.

The remaining process is the same, except that the bytes are also represented in hexadecimal for display in the browser and included in the request’s Referer header before being sent to the server. The result looks like this:

The server receives the URL and decodes it with URLDecoder using its configured character encoding. The underlying process follows the same principles described above.
The request headers are shown below.

The response headers are shown below.


Transfer-Encoding: chunked indicates that the response data may be large, so the server encodes and sends it in chunks.