aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_protocol.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-09-16 15:51:15 +0200
committerLoïc Hoguin <[email protected]>2012-09-17 13:57:28 +0200
commit6dbc1f9ef98eda6cfdffc0a47b68fb50eeb3863a (patch)
tree7e395e8aba07811cac5d364567bed26046c45257 /src/cowboy_protocol.erl
parentc1f5a2acb2bcd6e9ba549bf5d3c3fd0c6789aeae (diff)
downloadcowboy-6dbc1f9ef98eda6cfdffc0a47b68fb50eeb3863a.tar.gz
cowboy-6dbc1f9ef98eda6cfdffc0a47b68fb50eeb3863a.tar.bz2
cowboy-6dbc1f9ef98eda6cfdffc0a47b68fb50eeb3863a.zip
Add a private cowboy_req function to create a Req object
Private means you must not used it. It's meant for internal use.
Diffstat (limited to 'src/cowboy_protocol.erl')
-rw-r--r--src/cowboy_protocol.erl17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl
index ad0987b..9b04ec3 100644
--- a/src/cowboy_protocol.erl
+++ b/src/cowboy_protocol.erl
@@ -139,10 +139,8 @@ request({http_request, Method, {abs_path, AbsPath}, Version},
ConnAtom = if Keepalive < MaxKeepalive -> version_to_connection(Version);
true -> close
end,
- parse_header(#http_req{socket=Socket, transport=Transport,
- connection=ConnAtom, pid=self(), method=Method, version=Version,
- path=RawPath, raw_qs=Qs, onresponse=OnResponse, urldecode=URLDec},
- State#state{path_tokens=PathTokens});
+ parse_header(cowboy_req:new(Socket, Transport, ConnAtom, Method, Version,
+ RawPath, Qs, OnResponse, URLDec), State#state{path_tokens=PathTokens});
request({http_request, Method, '*', Version},
State=#state{socket=Socket, transport=Transport,
req_keepalive=Keepalive, max_keepalive=MaxKeepalive,
@@ -150,10 +148,8 @@ request({http_request, Method, '*', Version},
ConnAtom = if Keepalive < MaxKeepalive -> version_to_connection(Version);
true -> close
end,
- parse_header(#http_req{socket=Socket, transport=Transport,
- connection=ConnAtom, pid=self(), method=Method, version=Version,
- path= <<"*">>, raw_qs= <<>>, onresponse=OnResponse,
- urldecode=URLDec}, State#state{path_tokens='*'});
+ parse_header(cowboy_req:new(Socket, Transport, ConnAtom, Method, Version,
+ <<"*">>, <<>>, OnResponse, URLDec), State#state{path_tokens='*'});
request({http_request, _Method, _URI, _Version}, State) ->
error_terminate(501, State);
request({http_error, <<"\r\n">>},
@@ -427,9 +423,8 @@ error_terminate(Code, State=#state{socket=Socket, transport=Transport,
receive
{cowboy_req, resp_sent} -> ok
after 0 ->
- _ = cowboy_req:reply(Code, #http_req{
- socket=Socket, transport=Transport, onresponse=OnResponse,
- connection=close, pid=self(), resp_state=waiting}),
+ _ = cowboy_req:reply(Code, cowboy_req:new(Socket, Transport,
+ close, 'GET', {1, 1}, <<>>, <<>>, OnResponse, undefined)),
ok
end,
terminate(State).