What's the correct encoding of HTTP get request strings?

后端 未结 3 1039
余生分开走
余生分开走 2020-11-29 09:54

Does the HTTP standard or something define which encoding should be used on special characters before they are encoded in url with %XXs? If it doesn\'t define is there a way

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 10:46

    Per RFC 2616,

       CHAR           = 
    

    and

     token          = 1*
    
       separators     = "(" | ")" | "<" | ">" | "@"
                      | "," | ";" | ":" | "\" | <">
                      | "/" | "[" | "]" | "?" | "="
                      | "{" | "}" | SP | HT
    

    and URIs are tokens with various specific separators. So, in theory, nothing but US-ASCII should be there. (In practice, since the ISO-8859-1 extension to US-ASCII is used in many other spots in the HTTP specs, it's not unusual to find HTTP implementations which support ISO-8859-1 rather than just US-ASCII, but strictly speaking that's not standards-compliant HTTP).

提交回复
热议问题