question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTTPConnection should return urllib3.HTTPResponse instead of http.client.HTTPResponse

See original GitHub issue

Part 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 and HTTPConnection.getresponse in both urllib3 and http.client. This research should be posted into this issue.
  • Move the wrapping of http.client.HTTPResponse from HTTPConnectionPool to HTTPConnection
  • Update type hints for HTTPConnection
  • Add test cases for HTTPConnection directly returning a urllib3.response.HTTPResponse.
  • Change existing test cases for the new logic.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
sethmlarsoncommented, Jun 21, 2022

@shadycuz It sounds like you’re on the right path!

0reactions
shadycuzcommented, Oct 4, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found