Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

#8 Make jsonp/body_qs work even when contetnt type is text/plain

  • Loading branch information...
commit f9d12a19fc7adf42662a9d5deb05d3087f5eee74 1 parent a00cab5
@majek majek authored
Showing with 13 additions and 4 deletions.
  1. +13 −4 src/sockjs_http.erl
View
17 src/sockjs_http.erl
@@ -23,10 +23,19 @@ body({cowboy, Req}) -> {ok, Body, Req1} = cowboy_http_req:body(Req),
{Body, {cowboy, Req1}};
body({misultin, Req} = R) -> {Req:get(body), R}.
-body_qs({cowboy, Req}) -> {BodyQS, Req1} = cowboy_http_req:body_qs(Req),
- {proplists:get_value(<<"d">>, BodyQS),
- {cowboy, Req1}};
-body_qs({misultin, Req} = R) -> {proplists:get_value("d", Req:parse_post()), R}.
+body_qs(R) ->
+ case header('Content-Type', R) of
+ "text/plain" ->
+ body(R);
+ _ ->
+ %% Assume application/x-www-form-urlencoded by default
+ body_qs2(R)
+ end.
+
+body_qs2({cowboy, Req}) -> {BodyQS, Req1} = cowboy_http_req:body_qs(Req),
+ {proplists:get_value(<<"d">>, BodyQS),
+ {cowboy, Req1}};
+body_qs2({misultin, Req} = R) -> {proplists:get_value("d", Req:parse_post()), R}.
%% TODO fix Req mutation for these two
jsessionid({cowboy, Req}) ->

0 comments on commit f9d12a1

Please sign in to comment.
Something went wrong with that request. Please try again.