Skip to content
Browse files

Fix tests on Transfer-Encoding header to be case-insensitive

  • Loading branch information...
1 parent 5101fde commit f3a31fe1a31fff98882cac517c5cd6b6239a9dc8 @capflam capflam committed Sep 12, 2012
Showing with 14 additions and 8 deletions.
  1. +4 −2 src/yaws_revproxy.erl
  2. +5 −4 src/yaws_server.erl
  3. +3 −1 test/t2/posttest.erl
  4. +2 −1 test/t4/posttest.erl
View
6 src/yaws_revproxy.erl
@@ -92,9 +92,10 @@ out(#arg{state=#revproxy{}=RPState}=Arg) when RPState#revproxy.state == sendhead
HdrsStr = yaws:headers_to_str(NewHdrs),
case send(RPState, [ReqStr, "\r\n", HdrsStr, "\r\n"]) of
ok ->
+ TE = yaws:to_lower(Hdrs#headers.transfer_encoding),
RPState1 = if
(Hdrs#headers.content_length == undefined andalso
- Hdrs#headers.transfer_encoding == "chunked") ->
+ TE == "chunked") ->
?Debug("Request content is chunked~n", []),
RPState#revproxy{state=sendchunk};
true ->
@@ -248,7 +249,8 @@ out(#arg{state=RPState}=Arg) when RPState#revproxy.state == recvheaders ->
RPState2 =
case RespHdrs#headers.content_length of
undefined ->
- case RespHdrs#headers.transfer_encoding of
+ TE = yaws:to_lower(RespHdrs#headers.transfer_encoding),
+ case TE of
"chunked" ->
?Debug("Response content is chunked~n",
[]),
View
9 src/yaws_server.erl
@@ -1512,7 +1512,7 @@ body_method(CliSock, IPPort, Req, Head) ->
PPS = SC#sconf.partial_post_size,
Res = case Head#headers.content_length of
undefined ->
- case Head#headers.transfer_encoding of
+ case yaws:to_lower(Head#headers.transfer_encoding) of
"chunked" ->
get_chunked_client_data(CliSock, yaws:is_ssl(SC));
_ ->
@@ -3256,10 +3256,11 @@ handle_out_reply(Arg = #arg{}, _LineNo, _YawsFile, _UT, _ARG) ->
Arg;
handle_out_reply(flush, _LineNo, _YawsFile, _UT, ARG) ->
+ Hdrs = ARG#arg.headers,
CliDataPos0 = get(client_data_pos),
CliDataPos1 = flush(ARG#arg.clisock, CliDataPos0,
- (ARG#arg.headers)#headers.content_length,
- (ARG#arg.headers)#headers.transfer_encoding),
+ Hdrs#headers.content_length,
+ yaws:to_lower(Hdrs#headers.transfer_encoding)),
put(client_data_pos, CliDataPos1),
ok;
@@ -3666,7 +3667,7 @@ get_more_post_data(PPS, ARG) ->
N = SC#sconf.partial_post_size,
case (ARG#arg.headers)#headers.content_length of
undefined ->
- case (ARG#arg.headers)#headers.transfer_encoding of
+ case yaws:to_lower((ARG#arg.headers)#headers.transfer_encoding) of
"chunked" ->
get_chunked_client_data(ARG#arg.clisock, yaws:is_ssl(SC));
_ ->
View
4 test/t2/posttest.erl
@@ -8,8 +8,9 @@ out(Arg) ->
Url = yaws_api:request_url(Arg),
case Url#url.path of
"/posttest/chunked/" ++ ExpectedSize ->
+ TE = yaws:to_lower((Arg#arg.headers)#headers.transfer_encoding),
if
- (Arg#arg.headers)#headers.transfer_encoding =:= "chunked" ->
+ TE =:= "chunked" ->
handle_post(list_to_integer(ExpectedSize), Arg);
true ->
Reason = io_lib:format("Expected a chunked transfer-encoding request\n~p",
@@ -24,6 +25,7 @@ out(Arg) ->
end.
+
handle_post(_, #arg{clidata=Data, state={flush, HttpCode, Reason}}) ->
%% Catch an error here but flush all remaining data.
case Data of
View
3 test/t4/posttest.erl
@@ -8,8 +8,9 @@ out(Arg) ->
Url = yaws_api:request_url(Arg),
case Url#url.path of
"/posttest/chunked/" ++ ExpectedSize ->
+ TE = yaws:to_lower((Arg#arg.headers)#headers.transfer_encoding),
if
- (Arg#arg.headers)#headers.transfer_encoding =:= "chunked" ->
+ TE =:= "chunked" ->
handle_post(list_to_integer(ExpectedSize), Arg);
true ->
Reason = io_lib:format("Expected a chunked transfer-encoding request\n~p",

0 comments on commit f3a31fe

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