hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Url contain comma cause exception

Open dailin opened this issue 6 years ago • 1 comments

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?

dailin avatar Feb 01 '19 09:02 dailin

[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.

rainbowFi avatar Oct 25 '19 14:10 rainbowFi