|
|
@@ -136,6 +136,8 @@ parse(<<>>, Parser) ->
|
|
|
|
|
|
parse(Bytes, #{phase := body, length := Len, state := State}) ->
|
|
|
parse(body, Bytes, State, Len);
|
|
|
+parse(Bytes, #{phase := Phase, state := State}) when Phase =/= none ->
|
|
|
+ parse(Phase, Bytes, State);
|
|
|
|
|
|
parse(Bytes, Parser = #{pre := Pre}) ->
|
|
|
parse(<<Pre/binary, Bytes/binary>>, maps:without([pre], Parser));
|
|
|
@@ -162,6 +164,8 @@ parse(command, <<?LF, Rest/binary>>, State = #parser_state{acc = Acc}) ->
|
|
|
parse(headers, Rest, State#parser_state{cmd = Acc, acc = <<>>});
|
|
|
parse(command, <<Ch:8, Rest/binary>>, State) ->
|
|
|
parse(command, Rest, acc(Ch, State));
|
|
|
+parse(command, <<>>, State) ->
|
|
|
+ {more, #{phase => command, state => State}};
|
|
|
|
|
|
parse(headers, <<?LF, Rest/binary>>, State) ->
|
|
|
parse(body, Rest, State, content_len(State#parser_state{acc = <<>>}));
|
|
|
@@ -174,6 +178,8 @@ parse(hdname, <<?COLON, Rest/binary>>, State = #parser_state{acc = Acc}) ->
|
|
|
parse(hdvalue, Rest, State#parser_state{hdname = Acc, acc = <<>>});
|
|
|
parse(hdname, <<Ch:8, Rest/binary>>, State) ->
|
|
|
parse(hdname, Rest, acc(Ch, State));
|
|
|
+parse(hdname, <<>>, State) ->
|
|
|
+ {more, #{phase => hdname, state => State}};
|
|
|
|
|
|
parse(hdvalue, <<?LF, Rest/binary>>,
|
|
|
State = #parser_state{headers = Headers, hdname = Name, acc = Acc}) ->
|
|
|
@@ -183,7 +189,9 @@ parse(hdvalue, <<?LF, Rest/binary>>,
|
|
|
},
|
|
|
parse(headers, Rest, NState);
|
|
|
parse(hdvalue, <<Ch:8, Rest/binary>>, State) ->
|
|
|
- parse(hdvalue, Rest, acc(Ch, State)).
|
|
|
+ parse(hdvalue, Rest, acc(Ch, State));
|
|
|
+parse(hdvalue, <<>>, State) ->
|
|
|
+ {more, #{phase => hdvalue, state => State}}.
|
|
|
|
|
|
%% @private
|
|
|
parse(body, <<>>, State, Length) ->
|