Encoding problems in the http protocol

There are two types of HTTP protocol packets: request packets and response packets. These two types of packets have similar structures and consist of three parts, in order:

1) start line start line (request line in request message, status line in response message) such as: GET /index.jsp HTTP/ (CRLF)

2) header header such as: Accept: xxx Host: xxx User-Agent, etc.

3) body message body

 

Parts 1) and 2) must be ASCII characters

3) can be any encoding, it can be character encoding, it can be image encoding, etc., what is it, it is explained by Content-Type in 2)

 

In ASCII characters, some reserved characters cannot appear in some areas that appear directly in 1) and 2). For example: the reserved character "=", the address in the get method may contain parameters such as key=value, "=" cannot directly appear in the key and value, if the key is '=man', then it should be encoded as %3dman, where 3d is the hexadecimal representation of the ASCII code for "=". In principle, this percentage encoding is only used for reserved ascII codes, and now people have extended this method, using this method to encode complex characters, such as GB2312 and utf-8, etc., such as encoding the "good man" of GB2312 as %BA %C3%C8%CB, for example, the common %20 is the encoded appearance of the space character

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326563585&siteId=291194637