问题
With POST is easy and automatic: just use application/x-www-form-urlencoded or multipart/form-data or whatever.
Instead, what parts should be encoded in a GET request?
The whole query string? Just the parameter values but not the names? And the fragment?
Maybe also the path? But am pretty sure that I shouldn't encode the host or the scheme (since there are encoding and specs for international domains, like in japanese etc.). Hence the question is more about the URI 😉
Strangely I didn't find a clear specific answer to it on SO, nor it's easy to find one on the net.
回答1:
We have to encode the parts of the url (excluding the domain name) that may contain symbols and non ASCII characters excluding the slashes “/“ and the operands used by query strings (?, = and &).
Note: if you encode all the second part of the url together including the slashes and the operands used by the query strings, this part will be considered all as a single value and the url may not work properly.
来源:https://stackoverflow.com/questions/51292397/which-parts-of-a-url-need-to-be-encoded