0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Introduce cowboy_http_req:body_qs/1 for automated urlencoded body parsing.

This commit is contained in:
Loïc Hoguin 2011-03-22 13:20:21 +01:00
parent 775a03e6eb
commit 06274cd8ab

View file

@ -25,7 +25,7 @@
]). %% Request API. ]). %% Request API.
-export([ -export([
body/1, body/2 body/1, body/2, body_qs/1
]). %% Request Body API. ]). %% Request Body API.
-export([ -export([
@ -160,6 +160,12 @@ body(Length, Req=#http_req{socket=Socket, transport=Transport, body_state=waitin
{error, Reason} -> {error, Reason} {error, Reason} -> {error, Reason}
end. 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. %% Response API.
-spec reply(Code::http_status(), Headers::http_headers(), -spec reply(Code::http_status(), Headers::http_headers(),