std1.0.0-beta-7 SafeC docs

std :: http::http

Struct std::HttpRequest

#include <std/http/http.h> source

struct HttpRequest {
    struct String method;
    struct String path;
    struct String headers;
    struct String body;
}

Fields

§struct String methodsource
§struct String pathsource

the request-target as sent: "/a/b?x=1"

§struct String headerssource

raw header block, same shape as HttpResponse's

§struct String bodysource

Methods

§static struct HttpRequest new(const &char method, const &char path)source · definition

A request with this method and target and no headers or body — for tests and for calling a Router directly.

§struct String header(const &char name) constsource · definition

Owned copy of the first value for 'name' (any case; empty if absent).

§int has_header(const &char name) constsource · definition
§struct HttpHeaders header_map() constsource · definition
§struct String path_only() constsource · definition

'path' up to the '?' (still percent-encoded), and the part after it (empty when there is none).

§struct String query_string() constsource · definition
§struct QueryParams query() constsource · definition

The decoded query parameters.

§struct QueryParams form() constsource · definition

The body parsed as application/x-www-form-urlencoded (regardless of Content-Type — check content_type_is() first if it matters).

§int content_type_is(const &char mime) constsource · definition

1 if the Content-Type's media type (before any ';') equals 'mime', ignoring case: req.content_type_is("application/json").

§struct String cookie(const &char name) constsource · definition

The value of cookie 'name' from the Cookie header(s); empty if unset.

§struct HttpRequest clone() constsource · definition
§void drop()source · definition
§void free() consumesource · definition

= drop()