aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_req.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-03-22 13:20:21 +0100
committerLoïc Hoguin <[email protected]>2011-03-22 13:20:21 +0100
commit06274cd8abbf7d23150c3cef64e0d1eb052b9ed7 (patch)
treed82682a6babcaecd7e44ec100ff869b360d57b05 /src/cowboy_http_req.erl
parent775a03e6ebc6f749d106a891c749ba53134881bd (diff)
downloadcowboy-06274cd8abbf7d23150c3cef64e0d1eb052b9ed7.tar.gz
cowboy-06274cd8abbf7d23150c3cef64e0d1eb052b9ed7.tar.bz2
cowboy-06274cd8abbf7d23150c3cef64e0d1eb052b9ed7.zip
Introduce cowboy_http_req:body_qs/1 for automated urlencoded body parsing.
Diffstat (limited to 'src/cowboy_http_req.erl')
-rw-r--r--src/cowboy_http_req.erl8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl
index 69b6c08..5a1ec2b 100644
--- a/src/cowboy_http_req.erl
+++ b/src/cowboy_http_req.erl
@@ -25,7 +25,7 @@
]). %% Request API.
-export([
- body/1, body/2
+ body/1, body/2, body_qs/1
]). %% Request Body API.
-export([
@@ -160,6 +160,12 @@ body(Length, Req=#http_req{socket=Socket, transport=Transport, body_state=waitin
{error, Reason} -> {error, Reason}
end.
+-spec body_qs(Req::#http_req{})
+ -> {list({Name::string(), Value::string()}), Req::#http_req{}}.
+body_qs(Req) ->
+ {ok, Body, Req2} = body(Req),
+ {parse_qs(binary_to_list(Body)), Req2}.
+
%% Response API.
-spec reply(Code::http_status(), Headers::http_headers(),