pub async fn receive_headers<'socket, 'headers, Socket: AsyncBufRead + ?Sized>(
socket: Pin<&'socket mut Socket>,
buffer: &'headers mut [u8],
headers: &'headers mut [Header<'headers>],
metadata: Metadata,
) -> Result<(Response<'headers>, Receive<'socket, Socket>)>Expand description
Receives an HTTP status line and response headers.
The socket parameter is the transport-layer socket over which the HTTP response will be
received. The buffer parameter is an application-provided buffer that will hold the response
headers. The headers parameter is an application-provided array that will be filled with the
decoded headers. The metadata parameter is the instance returned at the end of sending the
request body.
The 'socket lifetime parameter is the lifetime of socket, which, once this function
returns, must continue to live in the returned Receive. The 'headers lifetime
parameter is the lifetime of buffer and headers, which need only live as long as the
application wishes to examine the response headers. The Socket type parameter is the type of
socket.
On success, the headers along with the next stage of the operation, reading the response body, are returned.
ยงErrors
This function returns an error if reading from socket fails.
This function returns an error of kind InvalidData under
the following conditions:
- if the response status line or headers are malformed
- if the response status line and headers are too large to fit in
buffer - if there are too many response headers to fit in
headers - if the server sent a status code 101 Switching Protocols
- if multiple
Content-Lengthheaders are present - if the value of the
Content-Lengthheader is not a nonnegative integer - if the value of the
Content-Lengthheader is too large to represent in au64 - if the
Content-LengthandTransfer-Encodingheaders are both present - if the
Content-Lengthheader is present in a 204 No Content response - if multiple
Transfer-Encodingheaders are present - if the
Transfer-Encodingheader indicates an encoding other than chunked - if the
Transfer-Encodingheader is present in a 204 No Content response