[][src]Function aahc::receive_headers

pub async fn receive_headers<'socket, 'headers, Socket: AsyncBufRead + ?Sized>(
    __arg0: Pin<&'socket mut Socket>,
    buffer: &'headers mut [u8],
    headers: &'headers mut [Header<'headers>],
    metadata: Metadata
) -> Result<(Response<'headers>, Receive<'socket, Socket>)>

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-Length headers are present
  • if the value of the Content-Length header is not a nonnegative integer
  • if the value of the Content-Length header is too large to represent in a u64
  • if the Content-Length and Transfer-Encoding headers are both present
  • if the Content-Length header is present in a 204 No Content response
  • if multiple Transfer-Encoding headers are present
  • if the Transfer-Encoding header indicates an encoding other than chunked
  • if the Transfer-Encoding header is present in a 204 No Content response