api.md
This file
Path
docs/api.md
166 lines · 4.0 KiB · Markdown
Last changed by
Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919
History of this fileTake it
The walk stopped after 200 commits: lines older than 5ced56b point at it.
Expose ASGIDispatch & WSGIDispatch in the 'dispatch' namespace. (#407)Ahmed Maherbefore adoption5ced56b
lines 1–10why, one step back1# Developer Interface23## 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.10First pass at autodoc support (#464)Tom Christiebefore adoption1ce3cc3
lines 11–12why, one step back11::: httpx.request12 :docstring:Expose ASGIDispatch & WSGIDispatch in the 'dispatch' namespace. (#407)Ahmed Maherbefore adoption5ced56b
line 13why, one step back13First pass at autodoc support (#464)Tom Christiebefore adoption1ce3cc3
lines 14–15why, one step back14::: httpx.get15 :docstring:Expose ASGIDispatch & WSGIDispatch in the 'dispatch' namespace. (#407)Ahmed Maherbefore adoption5ced56b
line 16why, one step back16First pass at autodoc support (#464)Tom Christiebefore adoption1ce3cc3
lines 17–18why, one step back17::: httpx.options18 :docstring:Expose ASGIDispatch & WSGIDispatch in the 'dispatch' namespace. (#407)Ahmed Maherbefore adoption5ced56b
line 19why, one step back19First pass at autodoc support (#464)Tom Christiebefore adoption1ce3cc3
lines 20–21why, one step back20::: httpx.head21 :docstring:Expose ASGIDispatch & WSGIDispatch in the 'dispatch' namespace. (#407)Ahmed Maherbefore adoption5ced56b
line 22why, one step back22First pass at autodoc support (#464)Tom Christiebefore adoption1ce3cc3
lines 23–34why, one step back23::: httpx.post24 :docstring:2526::: httpx.put27 :docstring:2829::: httpx.patch30 :docstring:3132::: httpx.delete33 :docstring:34Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919
line 35why, one step back35## `Client`First pass at autodoc support (#464)Tom Christiebefore adoption1ce3cc3
line 36why, one step back36Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919
line 37why, one step back37::: httpx.ClientFirst pass at autodoc support (#464)Tom Christiebefore adoption1ce3cc3
line 38why, one step back38 :docstring:Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919
line 39why, one step back39 :members: headers cookies params request get head options post put patch delete build_request send closeExpose ASGIDispatch & WSGIDispatch in the 'dispatch' namespace. (#407)Ahmed Maherbefore adoption5ced56b
lines 40–58why, one step back4041## `Response`4243*An HTTP response.*4445* `def __init__(...)`46* `.status_code` - **int**47* `.reason_phrase` - **str**48* `.http_version` - `"HTTP/2"` or `"HTTP/1.1"`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]**58* `.elapsed` - **[timedelta](https://docs.python.org/3/library/datetime.html)**response.elapsed now reflects entire request/response time. (#692)Tom Christiebefore adoption6a1ee0e
line 59why, one step back59 * The amount of time elapsed between sending the request and calling `close()` on the corresponding response received for that request.Expose ASGIDispatch & WSGIDispatch in the 'dispatch' namespace. (#407)Ahmed Maherbefore adoption5ced56b
lines 60–63why, one step back60 [total_seconds()](https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds) to correctly get61 the total elapsed seconds.62* `def .raise_for_status()` - **None**63* `def .json()` - **Any**Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919
lines 64–70why, one step back64* `def .read()` - **bytes**65* `def .iter_raw()` - **async bytes iterator**66* `def .iter_bytes()` - **async bytes iterator**67* `def .iter_text()` - **async text iterator**68* `def .iter_lines()` - **async text iterator**69* `def .close()` - **None**70* `def .next()` - **Response**Rename 'read/close' to 'aread/aclose' on Response (#674)Florimond Mancabefore adoptionf9d18a8
line 71why, one step back71* `def .aread()` - **bytes**Fix out-of-date methods on Response API docs (#673)Florimond Mancabefore adoptione30ec85
lines 72–75why, one step back72* `def .aiter_raw()` - **async bytes iterator**73* `def .aiter_bytes()` - **async bytes iterator**74* `def .aiter_text()` - **async text iterator**75* `def .aiter_lines()` - **async text iterator**Rename 'read/close' to 'aread/aclose' on Response (#674)Florimond Mancabefore adoptionf9d18a8
line 76why, one step back76* `def .aclose()` - **None**Rename 'next' to 'anext' on Response (#676)Florimond Mancabefore adoption3462999
line 77why, one step back77* `def .anext()` - **Response**Expose ASGIDispatch & WSGIDispatch in the 'dispatch' namespace. (#407)Ahmed Maherbefore adoption5ced56b
lines 78–85why, one step back7879## `Request`8081*An HTTP request. Can be constructed explicitly for more control over exactly82what gets sent over the wire.*8384```python85>>> request = httpx.Request("GET", "https://example.org", headers={'host': 'example.org'})Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919
line 86why, one step back86>>> response = client.send(request)Expose ASGIDispatch & WSGIDispatch in the 'dispatch' namespace. (#407)Ahmed Maherbefore adoption5ced56b
lines 87–91why, one step back87```8889* `def __init__(method, url, [params], [data], [json], [headers], [cookies])`90* `.method` - **str**91* `.url` - **URL**Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919
line 92why, one step back92* `.content` - **byte**, **byte iterator**, or **byte async iterator**Expose ASGIDispatch & WSGIDispatch in the 'dispatch' namespace. (#407)Ahmed Maherbefore adoption5ced56b
lines 93–166why, one step back93* `.headers` - **Headers**94* `.cookies` - **Cookies**9596## `URL`9798*A normalized, IDNA supporting URL.*99100```python101>>> url = URL("https://example.org/")102>>> url.host103'example.org'104```105106* `def __init__(url, allow_relative=False, params=None)`107* `.scheme` - **str**108* `.authority` - **str**109* `.host` - **str**110* `.port` - **int**111* `.path` - **str**112* `.query` - **str**113* `.full_path` - **str**114* `.fragment` - **str**115* `.is_ssl` - **bool**116* `.origin` - **Origin**117* `.is_absolute_url` - **bool**118* `.is_relative_url` - **bool**119* `def .copy_with([scheme], [authority], [path], [query], [fragment])` - **URL**120* `def .resolve_with(url)` - **URL**121122## `Origin`123124*A normalized, IDNA supporting set of scheme/host/port info.*125126```python127>>> Origin('https://example.org') == Origin('HTTPS://EXAMPLE.ORG:443')128True129```130131* `def __init__(url)`132* `.scheme` - **str**133* `.is_ssl` - **bool**134* `.host` - **str**135* `.port` - **int**136137## `Headers`138139*A case-insensitive multi-dict.*140141```python142>>> headers = Headers({'Content-Type': 'application/json'})143>>> headers['content-type']144'application/json'145```146147* `def __init__(self, headers)`148149## `Cookies`150151*A dict-like cookie store.*152153```python154>>> cookies = Cookies()155>>> cookies.set("name", "value", domain="example.org")156```157158* `def __init__(cookies: [dict, Cookies, CookieJar])`159* `.jar` - **CookieJar**160* `def extract_cookies(response)`161* `def set_cookie_header(request)`162* `def set(name, value, [domain], [path])`163* `def get(name, [domain], [path])`164* `def delete(name, [domain], [path])`165* `def clear([domain], [path])`166* *Standard mutable mapping interface*