api.md
This file
Path
docs/api.md
161 lines · 4.0 KiB · Markdown
Last changed by
fix-1457: URL's full_path -> raw_path from pull #1285 in docs as well (#1458)David Bordeynikbefore adoption2847869
History of this fileTake it
The walk stopped after 200 commits: lines older than ccd4711 point at it.
Drop deprecated proxies API (#1058)Tom Christiebefore adoptionccd4711
lines 1–33why, 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.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:Add `response.next_request` (#1334)Tom Christiebefore adoption3f51392
line 34why, one step back34Add stream docstring (#1200)Joebefore adoption924fa8c
lines 35–36why, one step back35::: httpx.stream36 :docstring:Drop deprecated proxies API (#1058)Tom Christiebefore adoptionccd4711
lines 37–41why, one step back3738## `Client`3940::: httpx.Client41 :docstring:Add stream docstring (#1200)Joebefore adoption924fa8c
line 42why, one step back42 :members: headers cookies params auth request get head options post put patch delete stream build_request send closeDrop deprecated proxies API (#1058)Tom Christiebefore adoptionccd4711
lines 43–47why, one step back4344## `AsyncClient`4546::: httpx.AsyncClient47 :docstring:Add stream docstring (#1200)Joebefore adoption924fa8c
line 48why, one step back48 :members: headers cookies params auth request get head options post put patch delete stream build_request send acloseDrop deprecated proxies API (#1058)Tom Christiebefore adoptionccd4711
lines 49–65why, one step back495051## `Response`5253*An HTTP response.*5455* `def __init__(...)`56* `.status_code` - **int**57* `.reason_phrase` - **str**58* `.http_version` - `"HTTP/2"` or `"HTTP/1.1"`59* `.url` - **URL**60* `.headers` - **Headers**61* `.content` - **bytes**62* `.text` - **str**63* `.encoding` - **str**64* `.is_redirect` - **bool**65* `.request` - **Request**Add `response.next_request` (#1334)Tom Christiebefore adoption3f51392
line 66why, one step back66* `.next_request` - **Optional[Request]**Drop deprecated proxies API (#1058)Tom Christiebefore adoptionccd4711
lines 67–94why, one step back67* `.cookies` - **Cookies**68* `.history` - **List[Response]**69* `.elapsed` - **[timedelta](https://docs.python.org/3/library/datetime.html)**70 * The amount of time elapsed between sending the request and calling `close()` on the corresponding response received for that request.71 [total_seconds()](https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds) to correctly get72 the total elapsed seconds.73* `def .raise_for_status()` - **None**74* `def .json()` - **Any**75* `def .read()` - **bytes**76* `def .iter_raw()` - **bytes iterator**77* `def .iter_bytes()` - **bytes iterator**78* `def .iter_text()` - **text iterator**79* `def .iter_lines()` - **text iterator**80* `def .close()` - **None**81* `def .next()` - **Response**82* `def .aread()` - **bytes**83* `def .aiter_raw()` - **async bytes iterator**84* `def .aiter_bytes()` - **async bytes iterator**85* `def .aiter_text()` - **async text iterator**86* `def .aiter_lines()` - **async text iterator**87* `def .aclose()` - **None**88* `def .anext()` - **Response**8990## `Request`9192*An HTTP request. Can be constructed explicitly for more control over exactly93what gets sent over the wire.*94Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd
line 95why, one step back95```pyconDrop deprecated proxies API (#1058)Tom Christiebefore adoptionccd4711
lines 96–99why, one step back96>>> request = httpx.Request("GET", "https://example.org", headers={'host': 'example.org'})97>>> response = client.send(request)98```99Added missing Request __init__ parameters (#1456)Simon Willisonbefore adoptionc52e7d2
line 100why, one step back100* `def __init__(method, url, [params], [headers], [cookies], [content], [data], [files], [json], [stream])`Drop deprecated proxies API (#1058)Tom Christiebefore adoptionccd4711
lines 101–110why, one step back101* `.method` - **str**102* `.url` - **URL**103* `.content` - **byte**, **byte iterator**, or **byte async iterator**104* `.headers` - **Headers**105* `.cookies` - **Cookies**106107## `URL`108109*A normalized, IDNA supporting URL.*110Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd
line 111why, one step back111```pyconDrop deprecated proxies API (#1058)Tom Christiebefore adoptionccd4711
lines 112–123why, one step back112>>> url = URL("https://example.org/")113>>> url.host114'example.org'115```116117* `def __init__(url, allow_relative=False, params=None)`118* `.scheme` - **str**119* `.authority` - **str**120* `.host` - **str**121* `.port` - **int**122* `.path` - **str**123* `.query` - **str**fix-1457: URL's full_path -> raw_path from pull #1285 in docs as well (#1458)David Bordeynikbefore adoption2847869
line 124why, one step back124* `.raw_path` - **str**Drop deprecated proxies API (#1058)Tom Christiebefore adoptionccd4711
lines 125–134why, one step back125* `.fragment` - **str**126* `.is_ssl` - **bool**127* `.is_absolute_url` - **bool**128* `.is_relative_url` - **bool**129* `def .copy_with([scheme], [authority], [path], [query], [fragment])` - **URL**130131## `Headers`132133*A case-insensitive multi-dict.*134Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd
line 135why, one step back135```pyconDrop deprecated proxies API (#1058)Tom Christiebefore adoptionccd4711
lines 136–147why, one step back136>>> headers = Headers({'Content-Type': 'application/json'})137>>> headers['content-type']138'application/json'139```140141* `def __init__(self, headers, encoding=None)`142* `def copy()` - **Headers**143144## `Cookies`145146*A dict-like cookie store.*147Use pycon for Python console code blocks (#1187)Hugo van Kemenadebefore adoptiond10b7cd
line 148why, one step back148```pyconDrop deprecated proxies API (#1058)Tom Christiebefore adoptionccd4711
lines 149–161why, one step back149>>> cookies = Cookies()150>>> cookies.set("name", "value", domain="example.org")151```152153* `def __init__(cookies: [dict, Cookies, CookieJar])`154* `.jar` - **CookieJar**155* `def extract_cookies(response)`156* `def set_cookie_header(request)`157* `def set(name, value, [domain], [path])`158* `def get(name, [domain], [path])`159* `def delete(name, [domain], [path])`160* `def clear([domain], [path])`161* *Standard mutable mapping interface*