cowboy_req man page

cowboy_req — HTTP request and response


The cowboy_req module provides functions to access, manipulate and respond to requests.

The functions in this module follow patterns for their return types, based on the kind of function.

· access: Value

· action: ok | {Result, Req} | {Result, Value, Req}

· modification: Req

· question: boolean()

Whenever Req is returned, you must use this returned value and ignore any previous you may have had. This value contains various values which are necessary for Cowboy to keep track of the request and response states.

All functions which perform an action should only be called once. This includes reading the request body or replying. Cowboy will throw an error on the second call when it detects suspicious behavior.

It is highly discouraged to pass the Req object to another process. Doing so and calling cowboy_req functions from it leads to undefined behavior.


body_opts() = [Option]

Option = {continue, boolean()}
        | {length, non_neg_integer()}
        | {read_length, non_neg_integer()}
        | {read_timeout, timeout()}
        | {transfer_decode, transfer_decode_fun(), any()}
        | {content_decode, content_decode_fun()}

Request body reading options.

req() - opaque to the user

The Req object.

All functions in this module receive a Req as argument, and some of them return a new object labelled Req2 in the function descriptions below.