No matching definitions.

httpd/write

src/httpd/write.tur

HTTP/1.1 response serializer.

Since: H5

defn

serialize-response

(serialize-response [resp : int] :)

render a Response into a wire-format byte buffer.

resp:int Response handle produced by httpd/response constructors.

:int -- Wbuf handle. Read its bytes/length with wbuf-bytes / wbuf-len, then release it with free-wbuf. The caller still owns resp; serialize-response does not consume it.

(let [r (resp-ok "text/plain" "Hello")
        w (serialize-response r)]
    (write fd (wbuf-bytes w) (wbuf-len w))
    (free-wbuf w)
    (free-response r))

Since: H5

defn

wbuf-bytes

(wbuf-bytes [buf : int] :)

pointer to the serialized response bytes.

buf:int Wbuf handle from serialize-response.

:cstr -- pointer to the serialized bytes.

(wbuf-bytes w)  ; => "HTTP/1.1 200 OK\r\n..."

Since: H5

defn

wbuf-len

(wbuf-len [buf : int] :)

number of bytes in the serialized response (excludes trailing NUL).

buf:int Wbuf handle from serialize-response.

:int -- byte count to pass to write(2) / send(2).

(wbuf-len w)  ; => 64

Since: H5

defn

free-wbuf

(free-wbuf [buf : int] :)

release a Wbuf handle and its underlying byte buffer.

buf:int Wbuf handle, or 0 (no-op).

:void

(free-wbuf w)

Since: H5