Abstract module mochiweb_request [Socket, Method, RawPath, Version, Headers]

MochiWeb HTTP Request abstraction.

Copyright © 2007 Mochi Media, Inc.

Authors: Bob Ippolito (bob@mochimedia.com).

Description

MochiWeb HTTP Request abstraction.

Data Types

field()

field() = socket | method | raw_path | version | headers | peer | path | body_length | range

headers()

abstract datatype: headers()

A mochiweb_headers structure.

iodata()

iodata() = binary() | iolist()

ioheaders()

ioheaders() = headers() | [{key(), value()}]

iolist()

iolist() = [iolist() | binary() | char()]

key()

key() = atom() | string() | binary()

response()

abstract datatype: response()

A mochiweb_response parameterized module instance.

value()

value() = atom() | string() | binary() | integer()

Function Index

cleanup/0Clean up any junk in the process dictionary, required before continuing a Keep-Alive request.
dump/0Dump the internal representation to a "human readable" set of terms for debugging/inspection purposes.
get/1Return the internal representation of the given field.
get_cookie_value/1Get the value of the given cookie.
get_header_value/1Get the value of a given request header.
get_primary_header_value/1
not_found/0Alias for not_found([]).
not_found/1Alias for respond({404, [{"Content-Type", "text/plain"} | ExtraHeaders], <<"Not found.">>}).
ok/1respond({200, [{"Content-Type", ContentType} | Headers], Body}).
parse_cookie/0Parse the cookie header.
parse_post/0Parse an application/x-www-form-urlencoded form POST.
parse_qs/0Parse the query string of the URL.
recv/1Receive Length bytes from the client as a binary, with the default idle timeout.
recv/2Receive Length bytes from the client as a binary, with the given Timeout in msec.
recv_body/0Receive the body of the HTTP request (defined by Content-Length).
recv_body/1Receive the body of the HTTP request (defined by Content-Length).
respond/1Start the HTTP response with start_response, and send Body to the client (if the get(method) /= 'HEAD').
send/1Send data over the socket.
serve_file/2Serve a file relative to DocRoot.
serve_file/3Serve a file relative to DocRoot.
should_close/0Return true if the connection must be closed.
start_raw_response/1Start the HTTP response by sending the Code HTTP response and ResponseHeaders.
start_response/1Start the HTTP response by sending the Code HTTP response and ResponseHeaders.
start_response_length/1Start the HTTP response by sending the Code HTTP response and ResponseHeaders including a Content-Length of Length.
test/0

Function Details

cleanup/0

cleanup() -> ok

Clean up any junk in the process dictionary, required before continuing a Keep-Alive request.

dump/0

dump() -> {mochiweb_request, [{atom(), term()}]}

Dump the internal representation to a "human readable" set of terms for debugging/inspection purposes.

get/1

get(X1::field()) -> term()

Return the internal representation of the given field.

get_cookie_value/1

get_cookie_value(Key::string) -> string() | undefined

Get the value of the given cookie.

get_header_value/1

get_header_value(K) -> undefined | Value

Get the value of a given request header.

get_primary_header_value/1

get_primary_header_value(K) -> any()

not_found/0

not_found() -> response()

Alias for not_found([]).

not_found/1

not_found(ExtraHeaders) -> response()

Alias for respond({404, [{"Content-Type", "text/plain"} | ExtraHeaders], <<"Not found.">>}).

ok/1

ok(X1::{value(), iodata()} | {value(), ioheaders(), iodata() | {file, IoDevice}}) -> response()

respond({200, [{"Content-Type", ContentType} | Headers], Body}).

parse_cookie/0

parse_cookie() -> [{Key::string(), Value::string()}]

Parse the cookie header.

parse_post/0

parse_post() -> [{Key::string(), Value::string()}]

Parse an application/x-www-form-urlencoded form POST. This has the side-effect of calling recv_body().

parse_qs/0

parse_qs() -> [{Key::string(), Value::string()}]

Parse the query string of the URL.

recv/1

recv(Length::integer()) -> binary()

Receive Length bytes from the client as a binary, with the default idle timeout.

recv/2

recv(Length::integer(), Timeout::integer()) -> binary()

Receive Length bytes from the client as a binary, with the given Timeout in msec.

recv_body/0

recv_body() -> binary()

Receive the body of the HTTP request (defined by Content-Length). Will only receive up to the default max-body length of 1MB.

recv_body/1

recv_body(MaxBody::integer()) -> binary()

Receive the body of the HTTP request (defined by Content-Length). Will receive up to MaxBody bytes.

respond/1

respond(X1::{integer(), ioheaders(), iodata() | chunked | {file, IoDevice}}) -> response()

Start the HTTP response with start_response, and send Body to the client (if the get(method) /= 'HEAD'). The Content-Length header will be set by the Body length, and the server will insert header defaults.

send/1

send(Data::iodata()) -> ok

Send data over the socket.

serve_file/2

serve_file(Path, DocRoot) -> Response

Serve a file relative to DocRoot.

serve_file/3

serve_file(Path, DocRoot, ExtraHeaders) -> Response

Serve a file relative to DocRoot.

should_close/0

should_close() -> bool()

Return true if the connection must be closed. If false, using Keep-Alive should be safe.

start_raw_response/1

start_raw_response(X1::{integer(), headers()}) -> response()

Start the HTTP response by sending the Code HTTP response and ResponseHeaders.

start_response/1

start_response(X1::{integer(), ioheaders()}) -> response()

Start the HTTP response by sending the Code HTTP response and ResponseHeaders. The server will set header defaults such as Server and Date if not present in ResponseHeaders.

start_response_length/1

start_response_length(X1::{integer(), ioheaders(), integer()}) -> response()

Start the HTTP response by sending the Code HTTP response and ResponseHeaders including a Content-Length of Length. The server will set header defaults such as Server and Date if not present in ResponseHeaders.

test/0

test() -> any()


Generated by EDoc, Aug 8 2008, 22:08:44.