Skip to content
Myr

api.md

This file

Path

docs/api.md

158 lines · 3.6 KiB · Markdown

Last changed by

Drop sync (#544)Tom Christiebefore adoption206c537

History of this file

Take it

The walk stopped after 200 commits: lines older than 7e9110b point at it.

Add additional flake8 plugins (#157)Can Sarıgölbefore adoption7e9110b

lines 1–2why, one step back
1# Developer Interface
2

Force HTTP/1.1 on short-lived connections (#284)Seth Michael Larsonbefore adoptione7aa6d6

line 3why, one step back
3## Helper Functions

Add additional flake8 plugins (#157)Can Sarıgölbefore adoption7e9110b

line 4why, one step back
4

Force HTTP/1.1 on short-lived connections (#284)Seth Michael Larsonbefore adoptione7aa6d6

lines 5–10why, one step back
5!!! note
6 Only use these functions if you're testing HTTPX in a console7 or making a small number of requests. Using a `Client` will8 enable HTTP/2 and connection pooling for more efficient and9 long-lived connections.10

First pass at autodoc support (#464)Tom Christiebefore adoption1ce3cc3

lines 11–12why, one step back
11::: httpx.request
12 :docstring:

Add additional flake8 plugins (#157)Can Sarıgölbefore adoption7e9110b

line 13why, one step back
13

First pass at autodoc support (#464)Tom Christiebefore adoption1ce3cc3

lines 14–15why, one step back
14::: httpx.get
15 :docstring:

Add additional flake8 plugins (#157)Can Sarıgölbefore adoption7e9110b

line 16why, one step back
16

First pass at autodoc support (#464)Tom Christiebefore adoption1ce3cc3

lines 17–18why, one step back
17::: httpx.options
18 :docstring:

Add additional flake8 plugins (#157)Can Sarıgölbefore adoption7e9110b

line 19why, one step back
19

First pass at autodoc support (#464)Tom Christiebefore adoption1ce3cc3

lines 20–21why, one step back
20::: httpx.head
21 :docstring:

Add additional flake8 plugins (#157)Can Sarıgölbefore adoption7e9110b

line 22why, one step back
22

First pass at autodoc support (#464)Tom Christiebefore adoption1ce3cc3

lines 23–38why, one step back
23::: httpx.post
24 :docstring:2526::: httpx.put27 :docstring:2829::: httpx.patch30 :docstring:3132::: httpx.delete33 :docstring:3435## `Client`3637::: httpx.Client38 :docstring:

Drop sync (#544)Tom Christiebefore adoption206c537

line 39why, one step back
39 :members: headers cookies params request get head options post put patch delete build_request send close

Add additional flake8 plugins (#157)Can Sarıgölbefore adoption7e9110b

lines 40–47why, one step back
40
41## `Response`4243*An HTTP response.*4445* `def __init__(...)`46* `.status_code` - **int**47* `.reason_phrase` - **str**

Response.protocol -> Response.http_version (#250)Tom Christiebefore adoptionc1ec1c3

line 48why, one step back
48* `.http_version` - `"HTTP/2"` or `"HTTP/1.1"`

Add additional flake8 plugins (#157)Can Sarıgölbefore adoption7e9110b

lines 49–57why, one step back
49* `.url` - **URL**
50* `.headers` - **Headers**51* `.content` - **bytes**52* `.text` - **str**53* `.encoding` - **str**54* `.is_redirect` - **bool**55* `.request` - **Request**56* `.cookies` - **Cookies**57* `.history` - **List[Response]**

Add `.elapsed` onto Response objects tracking how long a request took. (#351)Roy Williamsbefore adoption05ac117

lines 58–62why, one step back
58* `.elapsed` - **[timedelta](https://docs.python.org/3/library/datetime.html)**
59 * The amount of time elapsed between sending the first byte and parsing the headers (not including time spent reading60 the response). Use61 [total_seconds()](https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds) to correctly get62 the total elapsed seconds.

Add additional flake8 plugins (#157)Can Sarıgölbefore adoption7e9110b

lines 63–77why, one step back
63* `def .raise_for_status()` - **None**
64* `def .json()` - **Any**65* `def .read()` - **bytes**66* `def .stream()` - **bytes iterator**67* `def .raw()` - **bytes iterator**68* `def .close()` - **None**69* `def .next()` - **Response**7071## `Request`7273*An HTTP request. Can be constructed explicitly for more control over exactly74what gets sent over the wire.*7576```python77>>> request = httpx.Request("GET", "https://example.org", headers={'host': 'example.org'})

Drop sync (#544)Tom Christiebefore adoption206c537

line 78why, one step back
78>>> response = await client.send(request)

Add additional flake8 plugins (#157)Can Sarıgölbefore adoption7e9110b

lines 79–123why, one step back
79```
8081* `def __init__(method, url, [params], [data], [json], [headers], [cookies])`82* `.method` - **str**83* `.url` - **URL**84* `.content` - **byte** or **byte async iterator**85* `.headers` - **Headers**86* `.cookies` - **Cookies**8788## `URL`8990*A normalized, IDNA supporting URL.*9192```python93>>> url = URL("https://example.org/")94>>> url.host95'example.org'96```9798* `def __init__(url, allow_relative=False, params=None)`99* `.scheme` - **str**100* `.authority` - **str**101* `.host` - **str**102* `.port` - **int**103* `.path` - **str**104* `.query` - **str**105* `.full_path` - **str**106* `.fragment` - **str**107* `.is_ssl` - **bool**108* `.origin` - **Origin**109* `.is_absolute_url` - **bool**110* `.is_relative_url` - **bool**111* `def .copy_with([scheme], [authority], [path], [query], [fragment])` - **URL**112* `def .resolve_with(url)` - **URL**113114## `Origin`115116*A normalized, IDNA supporting set of scheme/host/port info.*117118```python119>>> Origin('https://example.org') == Origin('HTTPS://EXAMPLE.ORG:443')120True121```122123* `def __init__(url)`

Make Origin use scheme, not is_ssl (#168)Stephen Brown IIbefore adoption44beaa1

line 124why, one step back
124* `.scheme` - **str**

Add additional flake8 plugins (#157)Can Sarıgölbefore adoption7e9110b

lines 125–158why, one step back
125* `.is_ssl` - **bool**
126* `.host` - **str**127* `.port` - **int**128129## `Headers`130131*A case-insensitive multi-dict.*132133```python134>>> headers = Headers({'Content-Type': 'application/json'})135>>> headers['content-type']136'application/json'137```138139* `def __init__(self, headers)`140141## `Cookies`142143*A dict-like cookie store.*144145```python146>>> cookies = Cookies()147>>> cookies.set("name", "value", domain="example.org")148```149150* `def __init__(cookies: [dict, Cookies, CookieJar])`151* `.jar` - **CookieJar**152* `def extract_cookies(response)`153* `def set_cookie_header(request)`154* `def set(name, value, [domain], [path])`155* `def get(name, [domain], [path])`156* `def delete(name, [domain], [path])`157* `def clear([domain], [path])`158* *Standard mutable mapping interface*