2012-05-23 14:53:48 +02:00
|
|
|
%% Copyright (c) 2011-2012, Loïc Hoguin <essen@ninenines.eu>
|
2011-05-09 14:31:06 +02:00
|
|
|
%% Copyright (c) 2011, Anthony Ramine <nox@dev-extend.eu>
|
2011-03-07 22:59:22 +01:00
|
|
|
%%
|
|
|
|
%% Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
%% purpose with or without fee is hereby granted, provided that the above
|
|
|
|
%% copyright notice and this permission notice appear in all copies.
|
|
|
|
%%
|
|
|
|
%% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
%% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
%% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
%% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
%% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
%% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
-record(http_req, {
|
2011-03-20 18:03:11 +01:00
|
|
|
%% Transport.
|
2011-04-18 00:06:26 +02:00
|
|
|
socket = undefined :: undefined | inet:socket(),
|
2011-03-18 22:38:26 +01:00
|
|
|
transport = undefined :: undefined | module(),
|
|
|
|
connection = keepalive :: keepalive | close,
|
2011-03-20 18:03:11 +01:00
|
|
|
|
|
|
|
%% Request.
|
2012-01-02 09:41:30 +01:00
|
|
|
pid = undefined :: pid(),
|
2012-01-23 09:21:33 +01:00
|
|
|
method = 'GET' :: cowboy_http:method(),
|
2012-01-23 09:28:29 +01:00
|
|
|
version = {1, 1} :: cowboy_http:version(),
|
2012-03-12 21:57:07 +01:00
|
|
|
peer = undefined :: undefined |
|
|
|
|
{inet:ip_address(), inet:port_number()},
|
2011-10-01 02:32:20 +02:00
|
|
|
host = undefined :: undefined | cowboy_dispatcher:tokens(),
|
|
|
|
host_info = undefined :: undefined | cowboy_dispatcher:tokens(),
|
2011-05-05 14:03:39 +02:00
|
|
|
raw_host = undefined :: undefined | binary(),
|
2012-03-12 21:57:07 +01:00
|
|
|
port = undefined :: undefined | inet:port_number(),
|
2011-10-01 02:32:20 +02:00
|
|
|
path = undefined :: undefined | '*' | cowboy_dispatcher:tokens(),
|
|
|
|
path_info = undefined :: undefined | cowboy_dispatcher:tokens(),
|
2011-05-05 14:03:39 +02:00
|
|
|
raw_path = undefined :: undefined | binary(),
|
2011-05-25 23:02:40 +02:00
|
|
|
qs_vals = undefined :: undefined | list({binary(), binary() | true}),
|
2011-05-05 14:03:39 +02:00
|
|
|
raw_qs = undefined :: undefined | binary(),
|
2011-04-18 13:24:27 +02:00
|
|
|
bindings = undefined :: undefined | cowboy_dispatcher:bindings(),
|
2012-01-23 09:36:59 +01:00
|
|
|
headers = [] :: cowboy_http:headers(),
|
2011-10-05 03:17:13 +02:00
|
|
|
p_headers = [] :: [any()], %% @todo Improve those specs.
|
2012-01-23 09:39:17 +01:00
|
|
|
cookies = undefined :: undefined | [{binary(), binary()}],
|
2011-12-19 09:44:24 +01:00
|
|
|
meta = [] :: [{atom(), any()}],
|
2011-03-20 18:03:11 +01:00
|
|
|
|
2011-03-21 17:26:00 +01:00
|
|
|
%% Request body.
|
2012-03-29 01:14:44 +02:00
|
|
|
body_state = waiting :: waiting | done | {stream, fun(), any(), fun()}
|
|
|
|
| {multipart, non_neg_integer(), fun()},
|
2011-05-05 14:03:39 +02:00
|
|
|
buffer = <<>> :: binary(),
|
2011-03-21 17:26:00 +01:00
|
|
|
|
2011-03-20 18:03:11 +01:00
|
|
|
%% Response.
|
2011-11-28 09:09:41 +01:00
|
|
|
resp_state = waiting :: locked | waiting | chunks | done,
|
2012-01-23 09:36:59 +01:00
|
|
|
resp_headers = [] :: cowboy_http:headers(),
|
2012-01-23 09:46:40 +01:00
|
|
|
resp_body = <<>> :: iodata() | {non_neg_integer(),
|
|
|
|
fun(() -> {sent, non_neg_integer()})},
|
2011-12-05 01:08:38 +01:00
|
|
|
|
|
|
|
%% Functions.
|
2012-05-01 01:59:36 +02:00
|
|
|
onresponse = undefined :: undefined | fun((cowboy_http:status(),
|
|
|
|
cowboy_http:headers(), #http_req{}) -> #http_req{}),
|
2011-12-05 01:08:38 +01:00
|
|
|
urldecode :: {fun((binary(), T) -> binary()), T}
|
2011-03-07 22:59:22 +01:00
|
|
|
}).
|