httpserver
HTTP Server Helpers
Functions
| Function | Description |
|---|---|
_hsrv_byte_at | Internal byte reader. |
_hsrv_copy | Internal: copy bytes. |
_hsrv_starts | Internal: check if buf at off starts with prefix of plen bytes. |
_hsrv_find_body | Internal: find double CRLF (header/body separator). Returns offset or -1. |
_hsrv_write_http11 | Internal: write a string literal byte-by-byte. Returns new offset. Writes “HT… |
_hsrv_write_crlf | Internal: write CRLF. Returns new offset. |
_hsrv_write_int | Internal: write integer as decimal. Returns new offset. Handles values up to … |
http_parse_request | Parse an HTTP request. Returns handle. |
http_req_method | Get method code (0=GET, 1=POST, 2=PUT, 3=DELETE, 4=PATCH, 5=HEAD). |
http_req_path | Copy path to output buffer. Returns path length. |
http_req_path_len | Get path length. |
http_respond_ok | Format a 200 OK response with body. Returns total length in out. |
http_respond_404 | Format a 404 Not Found response. Returns total length in out. |
http_status_line | Format a status line for a given code. Returns length. |
Details
_hsrv_byte_at
fn _hsrv_byte_at(buf: &i8, idx: i64) -> i64Internal byte reader.
_hsrv_copy
fn _hsrv_copy(dst: &i8, doff: i64, src: &i8, soff: i64, len: i64) -> i64Internal: copy bytes.
_hsrv_starts
fn _hsrv_starts(buf: &i8, off: i64, pfx: &i8, plen: i64) -> i64Internal: check if buf at off starts with prefix of plen bytes.
_hsrv_find_body
fn _hsrv_find_body(buf: &i8, len: i64) -> i64Internal: find double CRLF (header/body separator). Returns offset or -1.
_hsrv_write_http11
fn _hsrv_write_http11(out: &i8, pos: i64) -> i64Internal: write a string literal byte-by-byte. Returns new offset. Writes “HTTP/1.1 " (9 bytes)
_hsrv_write_crlf
fn _hsrv_write_crlf(out: &i8, pos: i64) -> i64Internal: write CRLF. Returns new offset.
_hsrv_write_int
fn _hsrv_write_int(out: &i8, pos: i64, val: i64) -> i64Internal: write integer as decimal. Returns new offset. Handles values up to 99999 without alloc_pages.
http_parse_request
fn http_parse_request(buf: &i8, len: i64) -> &i64Parse an HTTP request. Returns handle.
http_req_method
fn http_req_method(h: &i64) -> i64Get method code (0=GET, 1=POST, 2=PUT, 3=DELETE, 4=PATCH, 5=HEAD).
http_req_path
fn http_req_path(h: &i64, out: &i8) -> i64Copy path to output buffer. Returns path length.
http_req_path_len
fn http_req_path_len(h: &i64) -> i64Get path length.
http_respond_ok
fn http_respond_ok(body: &i8, blen: i64, out: &i8) -> i64Format a 200 OK response with body. Returns total length in out.
http_respond_404
fn http_respond_404(out: &i8) -> i64Format a 404 Not Found response. Returns total length in out.
http_status_line
fn http_status_line(code: i64, out: &i8) -> i64Format a status line for a given code. Returns length.