Skip to content
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

Make BaseHTTPResponse a base class of HTTP2Response #3311

Merged
merged 4 commits into from Jan 24, 2024

Conversation

pquentin
Copy link
Member

Closes #3297

As mentioned in #3297, it turns out we already had version, an integer that tells us the HTTP version using a convention from http.client (10 means HTTP/1.0, 11 means HTTP/1.1 and 20 means HTTP/2.0). I'm happy to add an http_version string field too.

This pull request was sponsored by Elastic, my employer.

@pquentin pquentin added the Skip Changelog Pull requests that don't require a changelog entry label Jan 24, 2024
Copy link
Member

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one suggestion, otherwise LGTM!

@@ -556,7 +556,7 @@ def _make_request(
# HTTP version
http_version,
response.status,
response.length_remaining, # type: ignore[attr-defined]
getattr(response, "length_remaining", None),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add support for length_remaining in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean adding self.length_remaining = 0 or actually handling it correctly?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.length_remaining = 0 seems appropriate, the actual implementation can happen in the streaming issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. By the way, If we keep length_remaining eventually, this means we should probably add it to BaseHTTPResponse and fix the mypy error in the process.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed should be a part of BaseHTTPResponse.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recorded here: #3315

@sethmlarson
Copy link
Member

Also looks like we need to add a test for .data for coverage.

@pquentin pquentin merged commit 26a07db into urllib3:main Jan 24, 2024
33 checks passed
@pquentin pquentin deleted the base-http2-response branch January 24, 2024 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog Pull requests that don't require a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add http_version property to BaseHTTPResponse
3 participants