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
Fix HTTP version in debug log #3316
base: main
Are you sure you want to change the base?
Conversation
This trick was used in the hyper HTTP/2 client, and has two advantages: 1. it is impossible to use the connection without acquiring the lock 2. passing the connection to another object only requires one parameter
self.scheme, | ||
self.host, | ||
self.port, | ||
method, | ||
url, | ||
# HTTP version | ||
http_version, | ||
response.version, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on using *divmod(response.version, 10)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would give HTTP/2.0 which is less wrong but still weird? I think I would prefer storing the version string in the response? It can be done without any computation and only costs a few bytes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I do like HTTP/2 in the logs better too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this, we should probably keep emitting HTTP/1.1
and HTTP/2
since some folks might be using regular expressions on these values. Can we have an if
block that determines the value based on the resp.version
value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a way to avoid if
s, what do you think of a1f18b0?
@@ -482,6 +482,7 @@ def getresponse( # type: ignore[override] | |||
headers=headers, | |||
status=httplib_response.status, | |||
version=httplib_response.version, | |||
version_string=getattr(self, "_http_vsn_str", "HTTP/?"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emscripten has its own connection class, so I don't need the getattr any more:
version_string=getattr(self, "_http_vsn_str", "HTTP/?"), | |
version_string=self._http_vsn_str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I do need to add version_string
to
version=0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach LGTM, looks like a linting error and Emscripten tests failing.
Addresses #3297 (comment). It isn't great, but it will log HTTP/0 for emscripten, HTTP/20 for HTTP/2 and HTTP/11 for HTTP/1.1. Is it time to add an actual
http_version
orversion_string
inBaseHTTPResponse
alongsideversion
?