What are the implications of not doing url encoding when passing URLs in GET requests?
I just tried the following URL: http://www.google.com/search?hl=en&q=http://www.yahoo.com/path/to/location
on 开发者_Python百科my browser, and it worked! What made it work? And why should one encode URLs other than substituting spaces with + or %20, etc.? That is, do I still need to encode my URLs even if I don't have any characters that's not allowed in a valid URL?
Thanks for your time.
Your browser probably URL-endcoded the URL you typed before sending the request. You should be able to check this by inspecting the actual HTTP request. In Firefox, for example, you can do this with LiveHttpHeaders.
Browsers generally encode the url's automatically, and may or may not show it encoded. A PHP script may or may not encode it automatically... if it didn't it would lead to a URL parsing error or something.
精彩评论