Skip to content

picohttpparser #


picohttpparser is V implementation of picohttpparser, which in turn is "a tiny, primitive, fast HTTP request/response parser."

fn u64toa #

fn u64toa(buf_start &u8, value u64) !int

u64toa converts value to an ASCII string and stores it at buf_start. It returns the length of the ASCII string (branch lookup table implementation).

Note: buf_start should point to a memory buffer, that is at least 9 bytes long.

struct Request #

struct Request {
	prev_len int
pub mut:
	method      string
	path        string
	headers     [max_headers]Header
	num_headers int
	body        string

fn (Request) parse_request #

fn (mut r Request) parse_request(s string) !int

parse_request parses a raw HTTP request and returns the number of bytes read. -1 indicates a parse error and -2 means the request is parsed

fn (Request) parse_request_path #

fn (mut r Request) parse_request_path(s string) !int

parse_request_path sets the path and method fields

fn (Request) parse_request_path_pipeline #

fn (mut r Request) parse_request_path_pipeline(s string) !int

parse_request_path_pipeline can parse the path and method of HTTP/1.1 pipelines. Call it again to parse the next request

struct Response #

struct Response {
	fd        int
	date      &u8 = unsafe { nil }
	buf_start &u8 = unsafe { nil }
pub mut:
	buf &u8 = unsafe { nil }

fn (Response) write_string #

fn (mut r Response) write_string(s string)

fn (Response) http_ok #

fn (mut r Response) http_ok() &Response

fn (Response) header #

fn (mut r Response) header(k string, v string) &Response

fn (Response) header_date #

fn (mut r Response) header_date() &Response

fn (Response) header_server #

fn (mut r Response) header_server() &Response

fn (Response) content_type #

fn (mut r Response) content_type(s string) &Response

fn (Response) html #

fn (mut r Response) html() &Response

fn (Response) plain #

fn (mut r Response) plain() &Response

fn (Response) json #

fn (mut r Response) json() &Response

fn (Response) body #

fn (mut r Response) body(body string)

fn (Response) http_404 #

fn (mut r Response) http_404()

fn (Response) http_405 #

fn (mut r Response) http_405()

fn (Response) http_500 #

fn (mut r Response) http_500()

fn (Response) raw #

fn (mut r Response) raw(response string)

fn (Response) end #

fn (mut r Response) end() int