No matching definitions.

httpd/request

src/httpd/request.tur

read-only accessors for HTTP requests.

Since: H3 (a view over stdlib httpd since tourist-on-stdlib-httpd H2)

defn

request-view-new

(request-view-new [hconn ptr<void>] :)

internal: build the Request view of a stdlib conn.

hconnthe stdlib httpd conn of the current request

Request -- the view, or the null handle on allocation failure.

Since: tourist-on-stdlib-httpd H2

defn

request-view-free

(request-view-free [req : Request] :)

internal: release a view from request-view-new.

Since: tourist-on-stdlib-httpd H2

defn

req-method

(req-method [req : Request] :)

HTTP method of a parsed request.

reqRequest handle

:cstr -- uppercase method string, e.g. "GET", "POST"

(req-method req)  ; => "POST"

Since: H3

defn

req-path

(req-path [req : Request] :)

request-target path component (no query string).

reqRequest handle

:cstr -- path beginning with '/', e.g. "/foo/bar"

(req-path req)  ; => "/hello"

Since: H3

defn

req-query

(req-query [req : Request] :)

raw query string after '?', or "" if absent.

reqRequest handle

:cstr -- e.g. "name=world&id=1", or "" if the target had no '?'

(req-query req)  ; => "name=world"

Since: H3

defn

req-body

(req-body [req : Request] :)

request body bytes (NUL-terminated; length = Content-Length).

reqRequest handle

:cstr -- body content, or "" if the request had no body

(req-body req)  ; => "hello world"

Since: H3

defn

req-body-len

(req-body-len [req : Request] :)

length of the request body in bytes.

reqRequest handle

:int -- the byte count (0 when there was no body)

(req-body-len req)  ; => 11

Since: tourist-on-stdlib-httpd H2

defn

req-header

(req-header [req : Request name : cstr] :)

look up a request header by name (case-insensitive).

reqRequest handle
nameheader name, e.g. "Content-Type"

(Result cstr cstr) -- ok(value) if the header is present, err("not found") otherwise. Unwrap with ok-val / err-val.

(let [h (req-header req "Content-Type")]
    (when (ok? h) (println (ok-val h))))

Since: H3 (typed as Result in 0.2.0)

defn

request-conn

(request-conn [req : Request] :)

the stdlib httpd conn behind a Request.

reqRequest handle

(Option ptr<void>) -- some(conn) for a server-built Request, none otherwise.

(let [c (request-conn req)]
    (when (some? c) (httpd-req-cookie (unwrap c) "session")))

Since: tourist-on-stdlib-httpd H2

defn

req-remote-addr

(req-remote-addr [req : Request] :)

the IP address of the client that sent the request.

reqRequest handle

(Option cstr) -- some(address), or none when the Request was not built by the server or the address could not be read. The string lives as long as the request.

(let [a (req-remote-addr req)]
    (when (some? a) (println (unwrap a))))   ; prints 127.0.0.1

Since: tourist-on-stdlib-httpd H2