diff --git a/README.md b/README.md index 4fa8d65..9fcda9c 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ $ pip install git+https://github.com/encode/httpnext.git 200 >>> r.headers['content-type'] 'text/html; charset=UTF-8' ->>> r.text +>>> r.text() '\n\n\nExample Domain...' ``` diff --git a/docs/clients.md b/docs/clients.md index 6c944d6..7de4161 100644 --- a/docs/clients.md +++ b/docs/clients.md @@ -23,7 +23,7 @@ The client representation provides an indication of how many connections are cur ```{ .python .httpx } >>> r = cli.get("https://www.example.com") >>> r = cli.get("https://www.wikipedia.com") ->>> r = cli.get("https://www.theguardian.com") +>>> r = cli.get("https://www.theguardian.com/uk") >>> cli ``` @@ -31,7 +31,7 @@ The client representation provides an indication of how many connections are cur ```{ .python .ahttpx .hidden } >>> r = await cli.get("https://www.example.com") >>> r = await cli.get("https://www.wikipedia.com") ->>> r = await cli.get("https://www.theguardian.com") +>>> r = await cli.get("https://www.theguardian.com/uk") >>> cli ``` @@ -83,8 +83,6 @@ Client instances can be configured with a base URL that is used when constructin >>> r = cli.get("/json") >>> print(r) ->>> print(r.request.url) - ``` ```{ .python .ahttpx .hidden } @@ -92,8 +90,6 @@ Client instances can be configured with a base URL that is used when constructin >>> r = cli.get("/json") >>> print(r) ->>> print(r.request.url) - ``` ## Setting client headers @@ -135,7 +131,7 @@ The connection pool used by the client can be configured in order to customise t >>> no_verify.check_hostname = False >>> no_verify.verify_mode = ssl.CERT_NONE >>> # Instantiate a client with our custom SSL context. ->>> pool = httpx.ConnectionPool(ssl_context=no_verify): +>>> pool = httpx.ConnectionPool(ssl_context=no_verify) >>> with httpx.Client(transport=pool) as cli: >>> ... ``` diff --git a/docs/index.md b/docs/index.md index cb341cf..22d5fa8 100644 --- a/docs/index.md +++ b/docs/index.md @@ -15,11 +15,11 @@ A complete HTTP toolkit for Python. Supporting both client & server, and availab ```{ .shell .httpx } -$ pip install --pre httpx +$ pip install 'https://www.encode.io/httpnext/httpx-1.0.dev1-py3-none-any.whl' ``` ```{ .shell .ahttpx .hidden } -$ pip install --pre ahttpx +$ pip install 'https://www.encode.io/httpnext/ahttpx-1.0.dev1-py3-none-any.whl' ``` *Making requests as a client...* @@ -61,7 +61,7 @@ $ pip install --pre ahttpx >>> with httpx.serve_http(hello_world) as server: ... print(f"Serving on {server.url} (Press CTRL+C to quit)") -... server.serve() +... server.wait() Serving on http://127.0.0.1:8080/ (Press CTRL+C to quit) ``` @@ -72,7 +72,7 @@ Serving on http://127.0.0.1:8080/ (Press CTRL+C to quit) >>> async with httpx.serve_http(hello_world) as server: ... print(f"Serving on {server.url} (Press CTRL+C to quit)") -... await server.serve() +... await server.wait() Serving on http://127.0.0.1:8080/ (Press CTRL+C to quit) ``` @@ -107,11 +107,11 @@ Components provided by HTTPX are immutable by default, and provide tightly typed # Collaboration -The design repository for this work is currently private. We are looking towards a development model that encourages a calm focused working environment, and are currently taking a little time to work through expectations & boundaries for contributions to the codebase. +The repository for this project is currently private. -Getting to 1.0 has required reworking from the ground up, and presents a significantly sharper API than previous versions. Pin your dependencies. We are currently in prerelease mode. +We’re looking at creating paid opportunities for working on open source software which are properly compensated, flexible & well balanced. -This work is made possible through [project sponsorships](https://github.com/sponsors/encode). Your support is greatly appreciated. +If you're interested in collaborating, send an intro. --- diff --git a/docs/quickstart.md b/docs/quickstart.md index 3d0f6f7..1d8ecb6 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -5,11 +5,11 @@ Install using ... ```{ .shell .httpx } -$ pip install --pre httpx +$ pip install 'https://www.encode.io/httpnext/httpx-1.0.dev1-py3-none-any.whl' ``` ```{ .shell .ahttpx .hidden } -$ pip install --pre ahttpx +$ pip install 'https://www.encode.io/httpnext/ahttpx-1.0.dev1-py3-none-any.whl' ``` First, start by importing `httpx`... @@ -132,13 +132,13 @@ HTTPX will automatically handle decoding the response content into unicode text. ```{ .python .httpx } >>> r = httpx.get('https://www.example.org/') ->>> r.text() +>>> r.text '\n\n\nExample Domain...' ``` ```{ .python .ahttpx .hidden } >>> r = await ahttpx.get('https://www.example.org/') ->>> await r.text() +>>> r.text '\n\n\nExample Domain...' ``` diff --git a/docs/requests.md b/docs/requests.md index 23c66b1..ce8438c 100644 --- a/docs/requests.md +++ b/docs/requests.md @@ -135,7 +135,7 @@ Including direct file uploads... ## Accessing request content -... +*In progress...* diff --git a/docs/servers.md b/docs/servers.md index 8d5893c..295af20 100644 --- a/docs/servers.md +++ b/docs/servers.md @@ -3,13 +3,33 @@ The HTTP server provides a simple request/response API. This gives you a lightweight way to build web applications or APIs. -### `serve_http(endpoint, listeners=None)` +### `serve_http(endpoint)` ```{ .python .httpx } +>>> website = """ +... +... +... +... +... +...
hello, world
+... +... +... """ + >>> def hello_world(request): -... content = httpx.HTML('hello, world.') +... content = httpx.HTML(website) ... return httpx.Response(200, content=content) >>> with httpx.serve_http(hello_world) as server: @@ -19,8 +39,28 @@ Serving on http://127.0.0.1:8080/ (Press CTRL+C to quit) ``` ```{ .python .ahttpx .hidden } +>>> website = """ +... +... +... +... +... +...
hello, world
+... +... +... """ + >>> async def hello_world(request): -... content = httpx.HTML('hello, world.') +... content = httpx.HTML(website) ... return httpx.Response(200, content=content) >>> async with httpx.serve_http(hello_world) as server: @@ -29,11 +69,9 @@ Serving on http://127.0.0.1:8080/ (Press CTRL+C to quit) Serving on http://127.0.0.1:8080/ (Press CTRL+C to quit) ``` -## HTTPServer +--- -* `.wait()` -* `.url` -* `.connections` +*Docs in progress...* --- diff --git a/docs/templates/base.html b/docs/templates/base.html index 47a3938..22fe4d3 100644 --- a/docs/templates/base.html +++ b/docs/templates/base.html @@ -9,10 +9,30 @@ + + -