Merge pull request 'if a redirect with a body is provided, we need to skip the body' (!2) from fixes into main

Reviewed-on: #2
This commit is contained in:
Hannes Mehnert 2024-11-05 11:28:39 +00:00
commit 3e9b38787c
2 changed files with 8 additions and 0 deletions

View file

@ -434,6 +434,12 @@ let request
let rec follow_redirect count uri =
if count = 0 then Lwt.return_error (`Msg "Redirect limit exceeded")
else
let f response acc body =
if Status.is_redirection response.status then
Lwt.return acc
else
f response acc body
in
single_request ~ctx ~alpn_protocol ?config tls_config ~meth ~headers
?body uri f f_init
>>? fun (resp, body) ->

View file

@ -40,4 +40,6 @@ val request :
~max_redirect ~follow_redirect url body_f body_init] does a HTTP request
to [url] using [meth] and the HTTP protocol in [config]. The response is
the value of this function. The body is provided in chunks (see [body_f]).
If [follow_redirect] is enabled (true by default), [body_f] is not called
with the potential body of the redirection.
Reasonably defaults are used if not provided. *)