-
Notifications
You must be signed in to change notification settings - Fork 111
Add HTTP/2 support and protocol version logging #232
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
base: master
Are you sure you want to change the base?
Changes from 4 commits
210f59b
00ff8bf
5779bf1
dcc3285
0171e57
eccc6a1
e44d797
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,7 +141,8 @@ async def async_request(self, options_func, cancellation_event): | |
| uuid=uuid, | ||
| auth_key=auth_key, | ||
| client_request=None, | ||
| client_response=response | ||
| client_response=response, | ||
| http_version=f"HTTP/{response.version.major}.{response.version.minor}" if response.version else None | ||
| ) | ||
|
|
||
| # if body is not None and len(body) > 0 and not options.non_json_response: | ||
|
|
@@ -173,6 +174,10 @@ async def async_request(self, options_func, cancellation_event): | |
| data = "N/A" | ||
|
|
||
| logger.debug(data) | ||
| logger.debug( | ||
| "PubNub request completed: operation=%s protocol=%s" | ||
| % (options.operation_type, response_info.http_version) | ||
| ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| if response.status not in (200, 307, 204): | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,7 +193,8 @@ async def async_request(self, options_func, cancellation_event): | |
| uuid=uuid, | ||
| auth_key=auth_key, | ||
| client_request=None, | ||
| client_response=response | ||
| client_response=response, | ||
| http_version=response.http_version | ||
| ) | ||
|
|
||
| # if body is not None and len(body) > 0 and not options.non_json_response: | ||
|
|
@@ -225,6 +226,10 @@ async def async_request(self, options_func, cancellation_event): | |
| data = "N/A" | ||
|
|
||
| logger.debug(data) | ||
| logger.debug( | ||
| "PubNub request completed: operation=%s protocol=%s" | ||
| % (options.operation_type, response_info.http_version) | ||
| ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| if response.status_code not in (200, 307, 204): | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -174,7 +174,11 @@ def _build_envelope(self, p_options, e_options): | |
| origin=url.hostname, | ||
| uuid=uuid, | ||
| auth_key=auth_key, | ||
| client_request=res.request | ||
| client_request=res.request, | ||
| http_version=( | ||
|
parfeon marked this conversation as resolved.
|
||
| f"HTTP/{res.raw.version // 10}.{res.raw.version % 10}" | ||
| if res.raw and res.raw.version else None | ||
| ) | ||
| ) | ||
|
|
||
| if not res.ok: | ||
|
|
@@ -269,6 +273,16 @@ def _invoke_request(self, p_options, e_options, base_origin): | |
| try: | ||
| res = self.session.request(**args) | ||
| logger.debug("GOT %s" % res.text) | ||
|
|
||
| http_ver = ( | ||
| f"HTTP/{res.raw.version // 10}.{res.raw.version % 10}" | ||
| if res.raw and res.raw.version else "unknown" | ||
| ) | ||
| logger.debug( | ||
| "PubNub request completed: operation=%s protocol=%s" | ||
| % (e_options.operation_type, http_ver) | ||
| ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we actually print it if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's what I've been told to deliver: I'll try to make it less noisy and merge it with
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I've missed operation in the format. |
||
|
|
||
| except requests.exceptions.ConnectionError as e: | ||
| raise PubNubException( | ||
| pn_error=PNERR_CONNECTION_ERROR, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.