Repository navigation
Closed
Labels
priority: mediumMedium prioritystatus: in progressCurrently being worked ontype: bugSomething isn't workingtype: securityRelated to securityworkload: hoursLikely takes hours to resolve
Milestone
Description
Problem
Two gaps of foca.utils.http.GuardedClient, which gateways rely on to bound responses and to decide whether a request can be retried on another backend:
- Redirect bodies ignore the size limit. With
allow_redirects=False,requests.Session.send()still prepares the next request (forResponse.next) and reads the whole body of the redirect, without limit, beforeGuardedClientsees the response. Only the deadline ends the read. An invalidLocationheader raises an error at that point, too. Response hooks of authentication handlers (e.g.,HTTPDigestAuth) read bodies without limit in the same way. - Sent and not-sent errors are ambiguous.
RequestNotSentandRequestMaybeSentare told apart by the kind of error, but the same errors occur before and after sending. A TLS error while waiting for or reading a response is reported asRequestNotSent, so a gateway may submit the request a second time. A connection lost during the TLS handshake is reported asRequestMaybeSent, so a request that can safely be retried is not.
Proposal
- Don't let
requestshandle redirects, so that their bodies go through the size limit and they are returned like other responses. - Refuse authentication handlers with response hooks.
- Note when the first byte of a request goes out, and decide
RequestNotSentorRequestMaybeSentby that alone. Each reason code then means one or the other.
Acceptance criteria
- A redirect with an endless body gives
ResponseTooLarge, not a timeout; a redirect to an invalid URL is returned. - Tests for TLS errors and lost connections before and after sending.
docs/utilities.mdand the migration guide updated.
Metadata
Metadata
Assignees
Labels
priority: mediumMedium prioritystatus: in progressCurrently being worked ontype: bugSomething isn't workingtype: securityRelated to securityworkload: hoursLikely takes hours to resolve
Activity