HTTPConnection should return urllib3.HTTPResponse instead of http.client.HTTPResponse
See original GitHub issuePart of https://github.com/urllib3/urllib3/issues/1985
Currently our urllib3.connection.HTTPConnection
classes return directly a http.client.HTTPResponse
. This ties our APIs directly to http.client
which isn’t desirable for future additions of new HTTP protocol implementations.
Instead our HTTPConnection
APIs should return an instance of urllib3.response.HTTPResponse
directly and should be forwarded upwards instead of doing the wrapping inside of HTTPConnectionPool.urlopen
.
Minimum requirements
- Research and understand which exceptions can be raised at which stage from
HTTPConnection.urlopen
andHTTPConnection.getresponse
in both urllib3 and http.client. This research should be posted into this issue. - Move the wrapping of
http.client.HTTPResponse
fromHTTPConnectionPool
toHTTPConnection
- Update type hints for
HTTPConnection
- Add test cases for
HTTPConnection
directly returning aurllib3.response.HTTPResponse
. - Change existing test cases for the new logic.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
http.client — HTTP protocol client — Python 3.11.1 ...
This function returns an instance of http.client.HTTPMessage that holds the header fields, but no payload (the same as HTTPResponse.msg and http.server.
Read more >Response and Decoders - urllib3 1.26.13 documentation
Unread data in the HTTPResponse connection blocks the connection from being released back to the pool. Returns underlying file descriptor if one exists. ......
Read more >How do I overcome Python http.client.HTTPResponse objects?
For http and https urls, this function returns a http.client.HTTPResponse object which has the following HTTPResponse Objects methods.
Read more >Python HTTP at Lightspeed Part 2: urllib3 and requests
Like an HTTPConnection in the http module, urllib3 has a request() method. It's invoked like poolmanager.request('GET', 'http://httpbin.org/ ...
Read more >Python's urllib.request for HTTP Requests - Real Python
If you need to make HTTP requests with Python, then you may find ... be right to think about an HTTP response as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@shadycuz It sounds like you’re on the right path!
I think super is mostly fixed? I can’t remember. Still need to fix the bare raise bug. I did publish the first tool Deep-AST that makes it possible to parse all callable code.
I plan on releasing a second tool that will address the bug in the bare raise.