python-hyper / hyper

HTTP/2 for Python.
http://hyper.rtfd.org/en/latest/
MIT License
1.05k stars 191 forks source link

Url contain comma cause exception #400

Open dailin opened 5 years ago

dailin commented 5 years ago

eg: s = requests.Session() s.mount('https://www.cloudflare.com/', HTTP20Adapter())

when url don't contain commas r = s.get('https://www.cloudflare.com')

This is work well, but r = s.get('https://www.cloudflare.com?data={a,b}')

Commas cause the following errors: File "/Library/Python/2.7/site-packages/hpack/hpack.py", line 249, in encode for header in headers: File "/Library/Python/2.7/site-packages/h2/utilities.py", line 474, in inner for header in headers: File "/Library/Python/2.7/site-packages/h2/utilities.py", line 419, in _validate_host_authority_header for header in headers: File "/Library/Python/2.7/site-packages/h2/utilities.py", line 331, in _reject_pseudo_header_fields "Received duplicate pseudo-header field %s" % header[0] h2.exceptions.ProtocolError: Received duplicate pseudo-header field :path

How can i fix it?

rainbowFi commented 4 years ago

[I know this issue is old, but commenting because I found it when hitting the same error]

I hit this exception when the comma in the URL was not properly encoded. See https://www.w3schools.com/tags/ref_urlencode.asp for information about URL encoding. You can use urllib.urlencode in python to get a correctly encoded set of query parameters.