|
46 | 46 | %%% - `{ok, binary(), parser()}': on body, when a chunk has been |
47 | 47 | %%% parsed. To continue the parsing you must call |
48 | 48 | %%% `hackney_http:execute/1' with the given `parser()'. |
49 | | -%%% - `done': when the parsing is done |
50 | | -%%% - `{done, binary()}': on body, when no more need to be parsing. The binary |
| 49 | +%%% - `{done, binary()}': when the parsing is done. The binary |
51 | 50 | %%% given correpond to the non parsed part of the internal buffer. |
52 | 51 | %%% - `{error, term{}}': when an error happen |
53 | 52 |
|
|
83 | 82 | -type uri() :: binary(). |
84 | 83 | -type body_result() :: {more, parser(), binary()} |
85 | 84 | | {ok, binary(), parser()} |
86 | | - | {done, binary()} |
87 | | - | done. |
| 85 | + | {done, binary()}. |
88 | 86 |
|
89 | 87 | -type parser_result() :: |
90 | 88 | {response, http_version(), status(), http_reason(), parser()} |
@@ -328,20 +326,20 @@ parse_trailers(St, Acc) -> |
328 | 326 | end. |
329 | 327 |
|
330 | 328 | parse_body(St=#hparser{body_state=waiting, te=TE, clen=Length, |
331 | | - method=Method}) -> |
| 329 | + method=Method, buffer=Buffer}) -> |
332 | 330 | case TE of |
333 | 331 | <<"chunked">> -> |
334 | 332 | parse_body(St#hparser{body_state= |
335 | 333 | {stream, fun te_chunked/2, {0, 0}, fun ce_identity/1}}); |
336 | 334 | _ when Length =:= 0 orelse Method =:= <<"HEAD">> -> |
337 | | - done; |
| 335 | + {done, Buffer}; |
338 | 336 | _ -> |
339 | 337 | parse_body(St#hparser{body_state= |
340 | 338 | {stream, fun te_identity/2, {0, Length}, |
341 | 339 | fun ce_identity/1}}) |
342 | 340 | end; |
343 | | -parse_body(#hparser{body_state=done}) -> |
344 | | - done; |
| 341 | +parse_body(#hparser{body_state=done, buffer=Buffer}) -> |
| 342 | + {done, Buffer}; |
345 | 343 | parse_body(St=#hparser{buffer=Buffer, body_state={stream, _, _, _}}) |
346 | 344 | when Buffer =/= <<>> -> |
347 | 345 | transfer_decode(Buffer, St#hparser{buffer= <<>>}); |
@@ -389,7 +387,7 @@ transfer_decode(Data, St=#hparser{ |
389 | 387 | content_decode(ContentDecode, Data2, St#hparser{buffer=Rest, |
390 | 388 | body_state=done}); |
391 | 389 | done -> |
392 | | - done; |
| 390 | + {done, <<>>}; |
393 | 391 | {error, Reason} -> |
394 | 392 | {error, Reason} |
395 | 393 | end. |
|
0 commit comments