Force HTTP/1.1 on short-lived connections (#284)
This commit is contained in:
parent
8ea32e647f
commit
e7aa6d6710
@ -29,8 +29,8 @@ Let's get started...
|
||||
<Response [200 OK]>
|
||||
>>> r.status_code
|
||||
200
|
||||
>>> r.protocol
|
||||
'HTTP/2'
|
||||
>>> r.http_version
|
||||
'HTTP/1.1'
|
||||
>>> r.headers['content-type']
|
||||
'text/html; charset=UTF-8'
|
||||
>>> r.text
|
||||
|
||||
10
docs/api.md
10
docs/api.md
@ -1,6 +1,12 @@
|
||||
# Developer Interface
|
||||
|
||||
## Main Interface
|
||||
## Helper Functions
|
||||
|
||||
!!! note
|
||||
Only use these functions if you're testing HTTPX in a console
|
||||
or making a small number of requests. Using a `Client` will
|
||||
enable HTTP/2 and connection pooling for more efficient and
|
||||
long-lived connections.
|
||||
|
||||
* `get(url, [params], [headers], [cookies], [auth], [stream], [allow_redirects], [verify], [cert], [timeout])`
|
||||
* `options(url, [params], [headers], [cookies], [auth], [stream], [allow_redirects], [verify], [cert], [timeout])`
|
||||
@ -13,7 +19,7 @@
|
||||
|
||||
## `Client`
|
||||
|
||||
*An HTTP client, with connection pooling, redirects, cookie persistence, etc.*
|
||||
*An HTTP client, with connection pooling, HTTP/2, redirects, cookie persistence, etc.*
|
||||
|
||||
```python
|
||||
>>> client = httpx.Client()
|
||||
|
||||
@ -40,7 +40,7 @@ Let's get started...
|
||||
>>> r.status_code
|
||||
200
|
||||
>>> r.http_version
|
||||
'HTTP/2'
|
||||
'HTTP/1.1'
|
||||
>>> r.headers['content-type']
|
||||
'text/html; charset=UTF-8'
|
||||
>>> r.text
|
||||
|
||||
@ -33,7 +33,7 @@ def request(
|
||||
stream: bool = False,
|
||||
trust_env: bool = None,
|
||||
) -> Response:
|
||||
with Client() as client:
|
||||
with Client(http_versions=["HTTP/1.1"]) as client:
|
||||
return client.request(
|
||||
method=method,
|
||||
url=url,
|
||||
|
||||
@ -29,6 +29,7 @@ def test_get(server):
|
||||
assert response.status_code == 200
|
||||
assert response.reason_phrase == "OK"
|
||||
assert response.text == "Hello, world!"
|
||||
assert response.http_version == "HTTP/1.1"
|
||||
|
||||
|
||||
@threadpool
|
||||
|
||||
Loading…
Reference in New Issue
Block a user