HomeFreeBSD

libfetch: Add read buffering

Description

libfetch: Add read buffering

Previously, we would read FTP control connection messages and HTTP
reponse headers one character at a time. Now, we read as much as will
fit in our buffer and look for a newline. If there is data left over,
it will be reused by the next fetch_getln() call. This also requires
the addition of a fetch_bufread() which takes the buffer into account,
otherwise the start of the HTTP response body will be stuck in the
buffer after we read the last line of the header.

This should noticeably improve HTTP performance, especially for small
transfers.

MFC after: 1 week
Reviewed by: op
Differential Revision: https://reviews.freebsd.org/D57907

Details

Provenance
desAuthored on Jul 13 2026, 6:43 AM
Reviewer
op
Differential Revision
D57907: libfetch: Add read buffering
Parents
rG32c341bd1c8b: libfetch: Overhaul socket read / write
Branches
Unknown
Tags
Unknown