Skip to content
Myr

api.md

This file

Path

docs/api.md

157 lines · 3.9 KiB · Markdown

Last changed by

Expand client docstrings (#1152)Felix Hildénbefore adoptionf540bd0

History of this file

Take it

The walk stopped after 200 commits: lines older than 387f047 point at it.

Fixed redirect loop (#734)Yurii Ohorodnikbefore adoption387f047

lines 1–34why, one step back
1# Developer Interface
23## Helper Functions45!!! note6 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.1011::: httpx.request12 :docstring:1314::: httpx.get15 :docstring:1617::: httpx.options18 :docstring:1920::: httpx.head21 :docstring:2223::: httpx.post24 :docstring:2526::: httpx.put27 :docstring:2829::: httpx.patch30 :docstring:3132::: httpx.delete33 :docstring:34

Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919

line 35why, one step back
35## `Client`

Fixed redirect loop (#734)Yurii Ohorodnikbefore adoption387f047

line 36why, one step back
36

Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919

line 37why, one step back
37::: httpx.Client

Fixed redirect loop (#734)Yurii Ohorodnikbefore adoption387f047

line 38why, one step back
38 :docstring:

Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919

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

Fixed redirect loop (#734)Yurii Ohorodnikbefore adoption387f047

line 40why, one step back
40

Fix Client Docstring and add AsyncClient to API docs (#883)Ed Singletonbefore adoptionfc980e7

lines 41–44why, one step back
41## `AsyncClient`
4243::: httpx.AsyncClient44 :docstring:

Expand client docstrings (#1152)Felix Hildénbefore adoptionf540bd0

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

Fix Client Docstring and add AsyncClient to API docs (#883)Ed Singletonbefore adoptionfc980e7

lines 46–47why, one step back
46
47

Fixed redirect loop (#734)Yurii Ohorodnikbefore adoption387f047

lines 48–70why, one step back
48## `Response`
4950*An HTTP response.*5152* `def __init__(...)`53* `.status_code` - **int**54* `.reason_phrase` - **str**55* `.http_version` - `"HTTP/2"` or `"HTTP/1.1"`56* `.url` - **URL**57* `.headers` - **Headers**58* `.content` - **bytes**59* `.text` - **str**60* `.encoding` - **str**61* `.is_redirect` - **bool**62* `.request` - **Request**63* `.cookies` - **Cookies**64* `.history` - **List[Response]**65* `.elapsed` - **[timedelta](https://docs.python.org/3/library/datetime.html)**66 * The amount of time elapsed between sending the request and calling `close()` on the corresponding response received for that request.67 [total_seconds()](https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds) to correctly get68 the total elapsed seconds.69* `def .raise_for_status()` - **None**70* `def .json()` - **Any**

Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919

line 71why, one step back
71* `def .read()` - **bytes**

Document that iter_* methods are synchronous (#807)Colin Bounouarbefore adoptioncfe2278

lines 72–75why, one step back
72* `def .iter_raw()` - **bytes iterator**
73* `def .iter_bytes()` - **bytes iterator**74* `def .iter_text()` - **text iterator**75* `def .iter_lines()` - **text iterator**

Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919

lines 76–77why, one step back
76* `def .close()` - **None**
77* `def .next()` - **Response**

Fixed redirect loop (#734)Yurii Ohorodnikbefore adoption387f047

lines 78–92why, one step back
78* `def .aread()` - **bytes**
79* `def .aiter_raw()` - **async bytes iterator**80* `def .aiter_bytes()` - **async bytes iterator**81* `def .aiter_text()` - **async text iterator**82* `def .aiter_lines()` - **async text iterator**83* `def .aclose()` - **None**84* `def .anext()` - **Response**8586## `Request`8788*An HTTP request. Can be constructed explicitly for more control over exactly89what gets sent over the wire.*9091```python92>>> request = httpx.Request("GET", "https://example.org", headers={'host': 'example.org'})

Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919

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

Fixed redirect loop (#734)Yurii Ohorodnikbefore adoption387f047

lines 94–98why, one step back
94```
9596* `def __init__(method, url, [params], [data], [json], [headers], [cookies])`97* `.method` - **str**98* `.url` - **URL**

Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919

line 99why, one step back
99* `.content` - **byte**, **byte iterator**, or **byte async iterator**

Fixed redirect loop (#734)Yurii Ohorodnikbefore adoption387f047

lines 100–136why, one step back
100* `.headers` - **Headers**
101* `.cookies` - **Cookies**102103## `URL`104105*A normalized, IDNA supporting URL.*106107```python108>>> url = URL("https://example.org/")109>>> url.host110'example.org'111```112113* `def __init__(url, allow_relative=False, params=None)`114* `.scheme` - **str**115* `.authority` - **str**116* `.host` - **str**117* `.port` - **int**118* `.path` - **str**119* `.query` - **str**120* `.full_path` - **str**121* `.fragment` - **str**122* `.is_ssl` - **bool**123* `.is_absolute_url` - **bool**124* `.is_relative_url` - **bool**125* `def .copy_with([scheme], [authority], [path], [query], [fragment])` - **URL**126127## `Headers`128129*A case-insensitive multi-dict.*130131```python132>>> headers = Headers({'Content-Type': 'application/json'})133>>> headers['content-type']134'application/json'135```136

Increased test coverage & cleanup (#1003)Josep Cugatbefore adoption8c84210

lines 137–138why, one step back
137* `def __init__(self, headers, encoding=None)`
138* `def copy()` - **Headers**

Fixed redirect loop (#734)Yurii Ohorodnikbefore adoption387f047

lines 139–157why, one step back
139
140## `Cookies`141142*A dict-like cookie store.*143144```python145>>> cookies = Cookies()146>>> cookies.set("name", "value", domain="example.org")147```148149* `def __init__(cookies: [dict, Cookies, CookieJar])`150* `.jar` - **CookieJar**151* `def extract_cookies(response)`152* `def set_cookie_header(request)`153* `def set(name, value, [domain], [path])`154* `def get(name, [domain], [path])`155* `def delete(name, [domain], [path])`156* `def clear([domain], [path])`157* *Standard mutable mapping interface*