Expand description
HTTP primitives shared by the fetch and search paths: the user agent, the response-body cap, and the retry classification. Both paths previously carried their own copy of the last two and had drifted apart — search read bodies without any cap at all.
Constants§
- MAX_
BODY_ BYTES - Hard cap on the response body we will read (5 MiB). The HTML extractor turns a page into a few KB of text, so a multi-megabyte body is almost never worth the bandwidth, memory, and parse time — and an unbounded read is a DoS lever. Bodies over the cap are truncated (not errored): partial content is still useful and the extractor copes with truncated HTML.
- USER_
AGENT - The user agent both paths send.
Functions§
- read_
body_ capped - Read a response body, streaming chunks with a running byte cap so an
oversized body is bounded before it is ever parsed. The
boolin the error reports whether the read failure is transient (worth retrying). - read_
body_ capped_ bytes read_body_cappedwithout the decoding step, for callers that need to apply the response’s declared charset themselves.- transient_
send_ error - Is a send/connect failure worth retrying?
- transient_
status - Is a response status worth retrying? Server errors and explicit throttling.