Function receiveHead [src]

Prototype

pub fn receiveHead(s: *Server) ReceiveHeadError!Request

Parameters

s: *Server

Possible Errors

HttpConnectionClosing HeadError

The client sent 0 bytes of headers before closing the stream. This happens when a keep-alive connection is finally closed.

HttpHeadersInvalid

Client sent headers that did not conform to the HTTP protocol.

To find out more detailed diagnostics, Request.head_buffer can be passed directly to Request.Head.parse.

HttpHeadersOversize HeadError

Too many bytes of HTTP headers.

The HTTP specification suggests to respond with a 431 status code before closing the connection.

HttpRequestTruncated HeadError

Partial HTTP request was received but the connection was closed before fully receiving the headers.

ReadFailed HeadError

Transitive error occurred reading from in.

Source

pub fn receiveHead(s: *Server) ReceiveHeadError!Request { const head_buffer = try s.reader.receiveHead(); return .{ .server = s, .head_buffer = head_buffer, // No need to track the returned error here since users can repeat the // parse with the header buffer to get detailed diagnostics. .head = Request.Head.parse(head_buffer) catch return error.HttpHeadersInvalid, }; }