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.

Implement http_version attribute on BaseResponse object

See original GitHub issue

Currently, I am utilizing requests, which under the hood uses urllib3, whose HTTPResponse object contains a .version attribute, which is an int, ten times greater than the actual HTTP version (i.e. 10 for 1.0, 11 for 1.1, etc). I currently use it for logging my requests and responses in debug mode.

It would be good I think to implement a similar attribute (either version or more specifically http_version) for the BaseResponse object, for similar purposes, but perhaps use an actual float. What are your thoughts?

Proposal: BaseResponse.http_version: float = 0.0 # Could be a floatEnum with known HTTP versions

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
tomchristiecommented, Jun 25, 2019

Yup. So we’ve got response.protocol, which is a string and right now can be either "HTTP/2" or "HTTP/1.1".

We actually ought to improve on that by using the .http_version that h11 returns in order to return "HTTP/1.0" or "HTTP/0.9" when appropriate.

Its also possible that we might want to include a .protocol_value property which returns tuples such as eg. (1, 1) , (2, 0).

0reactions
StephenBrown2commented, Jun 28, 2019

I wouldn’t necessarily switch to http_version, as protocol makes sense the way that it is now, I’d just mention it in the API compatibility docs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implement http_version attribute on BaseResponse object #106
Currently, I am utilizing requests, which under the hood uses urllib3, whose HTTPResponse object contains a .version attribute, ...
Read more >
The Response Object — asks 1.3.6 documentation
The three parts of the status line are the HTTP-Version, Status-Code and Reason-Phrase. They can be accessed as attributes of the response object...
Read more >
c# - Creating Inherited Response Objects - Stack Overflow
I am writing some integration with a third-party eLearning platform that returns a variety of responses in different schemas depending on the ...
Read more >
API Reference — Bottle 0.13-dev documentation
This MultiDict subclass is used to store request form data. Additionally to the normal dict-like item access methods (which return unmodified data as...
Read more >
Request / Response Objects — Werkzeug Documentation (1.0 ...
Enforce that the WSGI response is a response object of the current type. Werkzeug will use the BaseResponse internally in many situations like...
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