Function respond [src]

Send an entire HTTP response to the client, including headers and body. Automatically handles HEAD requests by omitting the body. Unless transfer_encoding is specified, uses the "content-length" header. If the request contains a body and the connection is to be reused, discards the request body, leaving the Server in the ready state. If this discarding fails, the connection is marked as not to be reused and no error is surfaced. Asserts status is not continue. Asserts that "\r\n" does not occur in any header name or value.

Prototype

pub fn respond( request: *Request, content: []const u8, options: RespondOptions, ) ExpectContinueError!void

Parameters

request: *Requestcontent: []const u8options: RespondOptions

Possible Errors

HttpExpectationFailed

The client sent an expect HTTP header value other than "100-continue".

WriteFailed

Failed to write "HTTP/1.1 100 Continue\r\n\r\n" to the stream.

Source

pub fn respond( request: *Request, content: []const u8, options: RespondOptions, ) ExpectContinueError!void { try respondUnflushed(request, content, options); try request.server.out.flush(); }