Skip to content

Commit

Permalink
Merge pull request #4 from psytale/fix_tests
Browse files Browse the repository at this point in the history
Fix reconnect attempts and chunked response parsing
  • Loading branch information
dcorbacho committed Aug 8, 2014
2 parents 2f3328b + c28a423 commit 1ab4a09
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/fusco.erl
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ handle_call({request, Path, Method, Hdrs, Body, SendRetry}, From,
request = Request,
requester = From,
connection_header = ConHeader,
attempts = SendRetry}).
attempts = SendRetry + 1}).

%%--------------------------------------------------------------------
%% @private
Expand Down
6 changes: 4 additions & 2 deletions src/fusco_protocol.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ decode_status_line(<<"HTTP/1.0\s",C1,C2,C3,$\s,Rest/bits>>, Response) ->
decode_status_line(<<"HTTP/1.1\s",C1,C2,C3,$\s,Rest/bits>>, Response) ->
decode_reason_phrase(Rest, <<>>, Response#response{version = {1,1},
status_code = <<C1,C2,C3>>});
decode_status_line(Bin, Response = #response{size = Size}) when Size < 10 ->
decode_status_line(Bin, Response = #response{size = Size}) when Size < 13 ->
case fusco_sock:recv(Response#response.socket, Response#response.ssl) of
{ok, Data} ->
decode_status_line(<<Bin/binary, Data/binary>>, ?SIZE(Data, Response));
Expand Down Expand Up @@ -416,7 +416,9 @@ decode_cookie_av_value(<<C, Rest/bits>>, Co, AV, Value) ->
decode_cookie_av_value(Rest, Co, AV, <<Value/binary, C>>).


decode_body(<<>>, Response = #response{status_code = <<$1, _, _>>}) ->
decode_body(<<>>, Response = #response{status_code = <<$1, _, _>>,
transfer_encoding = TE})
when TE =/= <<"chunked">> ->
return(<<>>, Response);
decode_body(<<$\r, $\n, Rest/bits>>, Response) ->
decode_body(Rest, Response);
Expand Down
6 changes: 4 additions & 2 deletions test/fusco_protocol_eqc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ output_max_age(undefined) ->
output_max_age(Age) ->
list_to_integer(binary_to_list(Age)) * 1000000.

clear_record(Response) ->
clear_record(Response) when is_record(Response, response) ->
Response#response{socket = undefined,
ssl = undefined,
in_timestamp = undefined}.
in_timestamp = undefined};
clear_record(Error) ->
Error.

clear_connection(Response) when is_record(Response, response) ->
Response#response{connection = to_lower(Response#response.connection)};
Expand Down

0 comments on commit 1ab4a09

Please sign in to comment.