cauldron v0.1.7 Cauldron.Request protocol

Summary

Functions

Fetch the whole body from the request, or the rest if you used read before

Check if the request has a body

Get the headers used by the request

Get the method used by the request

Read a chunk from the request body, chunks are split respecting the chunk_size option of the listener

Read a chunk from the request body, chunks are split by the given size

Create a response for the request, it is not sent to allow for more fine-grained responses

Respond to the request sending a file or with just the response code

Respond to the request with the given code and body or with the given code and IO handle

Respond to the request with the given code, headers and body or with the given code and and generator function

Respond to the request with the given code, headers and generator function

Get the URI used by the request

Types

t()
t() :: term

Functions

body(self)
body(t) :: binary

Fetch the whole body from the request, or the rest if you used read before.

has_body?(self)
has_body?(t) :: boolean

Check if the request has a body.

headers(self)
headers(t) :: HTTProt.Headers.t

Get the headers used by the request.

method(self)
method(t) :: String.t

Get the method used by the request.

read(self)
read(t) :: binary

Read a chunk from the request body, chunks are split respecting the chunk_size option of the listener.

read(self, size)
read(t, non_neg_integer) :: binary

Read a chunk from the request body, chunks are split by the given size.

reply(self)

Create a response for the request, it is not sent to allow for more fine-grained responses.

reply(self, path_or_code)
reply(t, String.t | integer) :: none

Respond to the request sending a file or with just the response code.

reply(self, code, io_or_body)
reply(t, integer | {integer, String.t}, :io.device | iolist) :: none

Respond to the request with the given code and body or with the given code and IO handle.

reply(self, code, acc_or_headers, fun_or_body)
reply(t, integer, HTTProt.Headers.t | term, iolist | (term -> {iolist, term})) :: none

Respond to the request with the given code, headers and body or with the given code and and generator function.

reply(self, code, headers, acc, fun)
reply(t, integer, H.t, term, (term -> {iolist, term})) :: none

Respond to the request with the given code, headers and generator function.

uri(self)
uri(t) :: URI.t

Get the URI used by the request.