@@ -119,31 +119,26 @@ class HttpHeaderParser {
119
119
}
120
120
121
121
static size_t http_parser_execute_and_handle_pause (llhttp_t *parser,
122
- const char *data, size_t len, bool &paused )
122
+ const char *data, size_t len)
123
123
{
124
124
llhttp_errno_t rc = llhttp_get_errno (parser);
125
125
switch (rc) {
126
126
case HPE_PAUSED_UPGRADE:
127
127
llhttp_resume_after_upgrade (parser);
128
+ rc = llhttp_get_errno (parser);
128
129
goto happy_path;
129
130
case HPE_PAUSED:
130
131
llhttp_resume (parser);
132
+ rc = llhttp_get_errno (parser);
131
133
goto happy_path;
132
134
case HPE_OK:
135
+ rc = llhttp_execute (parser, data, len);
133
136
happy_path:
134
- switch (llhttp_execute (parser, data, len)) {
135
- case HPE_PAUSED_H2_UPGRADE:
136
- case HPE_PAUSED_UPGRADE:
137
- case HPE_PAUSED:
138
- paused = true ;
139
- return (llhttp_get_error_pos (parser) - data);
140
- case HPE_OK:
137
+ if (rc == HPE_OK) {
141
138
return len;
142
- default :
143
- goto error_path;
144
- }
139
+ }
140
+ // deliberate fall through
145
141
default :
146
- error_path:
147
142
return (llhttp_get_error_pos (parser) - data);
148
143
}
149
144
}
@@ -488,20 +483,22 @@ class HttpHeaderParser {
488
483
TRACE_POINT ();
489
484
P_ASSERT_EQ (message->httpState , Message::PARSING_HEADERS);
490
485
491
- size_t ret;
492
- bool paused;
493
-
494
486
state->parser .data = this ;
495
487
currentBuffer = &buffer;
496
- ret = http_parser_execute_and_handle_pause (&state->parser ,
497
- buffer.start , buffer.size (), paused );
488
+ size_t ret = http_parser_execute_and_handle_pause (&state->parser ,
489
+ buffer.start , buffer.size ());
498
490
currentBuffer = NULL ;
499
491
500
- if (!llhttp_get_upgrade (&state->parser ) && ret != buffer.size () && !paused || !paused && llhttp_get_errno (&state->parser ) != HPE_OK) {
492
+ llhttp_errno_t llerrno = llhttp_get_errno (&state->parser );
493
+
494
+ bool paused = (llerrno == HPE_PAUSED_H2_UPGRADE || llerrno == HPE_PAUSED_UPGRADE || llerrno == HPE_PAUSED);
495
+
496
+ if ( (!llhttp_get_upgrade (&state->parser ) && ret != buffer.size () && !paused) ||
497
+ (llerrno != HPE_OK && !paused) ) {
501
498
UPDATE_TRACE_POINT ();
502
499
message->httpState = Message::ERROR;
503
- switch (llhttp_get_errno (&state-> parser ) ) {
504
- case HPE_CB_HEADER_FIELD_COMPLETE:// ?? does this match was HPE_CB_header_field in old one
500
+ switch (llerrno ) {
501
+ case HPE_CB_HEADER_FIELD_COMPLETE:// does this match? was HPE_CB_header_field in old impl
505
502
case HPE_CB_HEADERS_COMPLETE:
506
503
switch (state->state ) {
507
504
case HttpHeaderParserState::ERROR_SECURITY_PASSWORD_MISMATCH:
@@ -526,9 +523,10 @@ class HttpHeaderParser {
526
523
break ;
527
524
default :
528
525
default_error:
529
- message->aux .parseError = HTTP_PARSER_ERRNO_BEGIN - llhttp_get_errno (&state-> parser ) ;
526
+ message->aux .parseError = HTTP_PARSER_ERRNO_BEGIN - llerrno ;
530
527
break ;
531
528
}
529
+ llhttp_finish (&state->parser );
532
530
} else if (messageHttpStateIndicatesCompletion (MessageType ())) {
533
531
UPDATE_TRACE_POINT ();
534
532
message->httpMajor = llhttp_get_http_major (&state->parser );
0 commit comments