]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Force HTTP/1.1 on short-lived connections (#284)
authorSeth Michael Larson <sethmichaellarson@gmail.com>
Tue, 27 Aug 2019 12:54:11 +0000 (07:54 -0500)
committerGitHub <noreply@github.com>
Tue, 27 Aug 2019 12:54:11 +0000 (07:54 -0500)
README.md
docs/api.md
docs/index.md
httpx/api.py
tests/test_api.py

index c8f68d77f64ca59b3987d311cf3c4c9cc47ac57b..1180ae8a7153b6269f1117ac1cc38dcdfd00ed26 100644 (file)
--- a/README.md
+++ b/README.md
@@ -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
index 5749b3ee4d0dc70572997e4c95bf8ce6635c1088..125c687e16f3d65045431016642a95c36bf0bf90 100644 (file)
@@ -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()
index 06a96f60f26b2af51bb83be8fcb968b5c381c154..949de8258410b0a333dc070f3009a5c04e622c87 100644 (file)
@@ -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
index fe52e14ed7f5678396397f1347c6913a9023e138..60d9ea7644b09736c71795592d228dcabc676060 100644 (file)
@@ -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,
index 7f636f3e3fc91ac47464f0e94802dd23ab0bb38c..de4267c713002627085c55340fb89f9164bcb8ff 100644 (file)
@@ -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