-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
requests removes characters from valid url #2404
Comments
The question mark indicates the beginning of the query portion of the URL. The octothorpe indicates the beginning of the fragment portion of the URL. We conclude that you have an empty query string and normalise it by removing the section entirely. If the octothorpe is intended to be part of the query string you need to percent-encode it to avoid ambiguity.
|
I understand. Many thanks for the quick response. Will close. |
@NikolaiT just to give you some more detail about this: The URI structure (that URLs follow) is of the form >>> import urllib.parse
>>> uri = urllib.parse.urlparse('http://incolumitas.com?#param=value')
>>> uri
ParseResult(scheme='http', netloc='incolumitas.com', path='', params='', query='', fragment='param=value')
>>> uri.geturl()
'http://incolumitas.com#param=value' According to this module (and the RFC that defines handling of URIs) these two URLs are equivalent. This can be seen by visiting both in your browser. In essence, if we didn't modify the URL it would be as valid as our current approach is. We do normalize URLs though because servers (and sometimes users) give us some rather bizarre URLs that will only "just work" when normalized. As core developers of a library whose core design goal is to make users' lives better, we need to take this approach to satisfy that goal. I hope that helps give you a deeper understanding of what's happening, why it is okay, and why it should happen. |
Requests strips the question mark when a hash tag follows. urlopen doesn't do it. Why?
Recreate bug with:
The text was updated successfully, but these errors were encountered: