From ea5ffce14f6a1430a3cb89eae573b388047f3f2c Mon Sep 17 00:00:00 2001 From: laggardkernel Date: Sun, 21 Mar 2021 22:59:31 +0800 Subject: [PATCH] Fix redirect description about HEAD (#1520) * Fix redirect description about HEAD * Apply suggestions from code review Co-authored-by: Florimond Manca --- docs/compatibility.md | 5 +++++ docs/quickstart.md | 13 ++----------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/docs/compatibility.md b/docs/compatibility.md index 99faf432..b71bc38c 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -124,6 +124,11 @@ On the other hand, HTTPX uses [HTTPCore](https://github.com/encode/httpcore) as `requests` omits `params` whose values are `None` (e.g. `requests.get(..., params={"foo": None})`). This is not supported by HTTPX. +## HEAD redirection + +In `requests`, all top-level API follow redirects by default except `HEAD`. +In consideration of consistency, we make `HEAD` follow redirects by default in HTTPX. + ## Determining the next redirect request When using `allow_redirects=False`, the `requests` library exposes an attribute `response.next`, which can be used to obtain the next redirect request. diff --git a/docs/quickstart.md b/docs/quickstart.md index 4f15549e..4afaff24 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -408,7 +408,8 @@ with additional API for accessing cookies by their domain or path. ## Redirection and History -By default, HTTPX will follow redirects for anything except `HEAD` requests. +By default, HTTPX will follow redirects for all HTTP methods. + The `history` property of the response can be used to inspect any followed redirects. It contains a list of any redirect responses that were followed, in the order @@ -436,16 +437,6 @@ You can modify the default redirection handling with the allow_redirects paramet [] ``` -If you’re making a `HEAD` request, you can use this to enable redirection: - -```pycon ->>> r = httpx.head('http://github.com/', allow_redirects=True) ->>> r.url -'https://github.com/' ->>> r.history -[] -``` - ## Timeouts HTTPX defaults to including reasonable timeouts for all network operations, -- 2.47.3