diff options
author | Loïc Hoguin <[email protected]> | 2012-04-29 01:20:24 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2012-04-29 15:22:20 +0200 |
commit | ee8c50c5ab97dcaebc8932d093741fdb496e00f7 (patch) | |
tree | 8e2b4e48361681cad25042ba85a22187ec452154 /src/cowboy_http_req.erl | |
parent | 845d306df68f37bb5246b0ce21b2a70456f042c4 (diff) | |
download | cowboy-ee8c50c5ab97dcaebc8932d093741fdb496e00f7.tar.gz cowboy-ee8c50c5ab97dcaebc8932d093741fdb496e00f7.tar.bz2 cowboy-ee8c50c5ab97dcaebc8932d093741fdb496e00f7.zip |
Fix and rework the HTTP test suite
Use a proper HTTP client to run all tests. This client is currently
undocumented and should not be used.
Includes a few fixes:
* Fix a bug in the max_keepalive test
* Fix a bug with max_keepalive handling
* Fix a bug in stream_body/1 where data was lost under some conditions
The tests now run quite faster than before.
All the tests now run twice: once for TCP, once for SSL.
Diffstat (limited to 'src/cowboy_http_req.erl')
-rw-r--r-- | src/cowboy_http_req.erl | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl index a6e8834..dfb73e7 100644 --- a/src/cowboy_http_req.erl +++ b/src/cowboy_http_req.erl @@ -456,10 +456,11 @@ stream_body(Req=#http_req{body_state=done}) -> -spec stream_body_recv(#http_req{}) -> {ok, binary(), #http_req{}} | {error, atom()}. -stream_body_recv(Req=#http_req{transport=Transport, socket=Socket}) -> +stream_body_recv(Req=#http_req{ + transport=Transport, socket=Socket, buffer=Buffer}) -> %% @todo Allow configuring the timeout. case Transport:recv(Socket, 0, 5000) of - {ok, Data} -> transfer_decode(Data, Req); + {ok, Data} -> transfer_decode(<< Buffer/binary, Data/binary >>, Req); {error, Reason} -> {error, Reason} end. @@ -477,7 +478,7 @@ transfer_decode(Data, Req=#http_req{ {stream, TransferDecode, TransferState2, ContentDecode}}); %% @todo {header(s) for chunked more -> - stream_body_recv(Req); + stream_body_recv(Req#http_req{buffer=Data}); {done, Length, Rest} -> Req2 = transfer_decode_done(Length, Rest, Req), {done, Req2}; |