Skip to content

Commit e4949a3

Browse files
author
Jeremy Williams
committed
Minor fixes
1 parent 443e85f commit e4949a3

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

httpserver.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ void hs_delete_events(struct http_request_s* request);
509509
void hs_add_events(struct http_request_s* request);
510510
void hs_add_write_event(struct http_request_s* request);
511511
void hs_process_tokens(http_request_t* request);
512+
void hs_read_and_process_request(http_request_t* request);
512513

513514
#ifdef KQUEUE
514515

@@ -610,7 +611,7 @@ char const * hs_status_text[] = {
610611
};
611612

612613
static int const hs_transitions[] = {
613-
// A-Z G-Z
614+
// A-F G-Z
614615
// spc \n \r : \t ; 0-9 a-f g-z tch vch etc
615616
/* ST start */ BR, BR, BR, BR, BR, BR, BR, MT, MT, MT, BR, BR,
616617
/* MT method */ MS, BR, BR, BR, BR, BR, MT, MT, MT, MT, BR, BR,
@@ -860,6 +861,7 @@ http_token_t hs_transition_action(
860861
break;
861862
case RR:
862863
case HR:
864+
// trigger meta end value on \r of request line and header
863865
hs_trigger_meta(parser, HS_META_END_VALUE);
864866
emitted = hs_stream_emit(stream);
865867
break;
@@ -884,9 +886,9 @@ http_token_t hs_transition_action(
884886
if (parser->meta == M_BIG || parser->meta == M_CHK) {
885887
emitted.type = HS_TOK_BODY_STREAM;
886888
}
887-
//if (parser->meta == M_CHK) parser->state = CS;
888889
hs_trigger_meta(parser, HS_META_END_HEADERS);
889890
if (parser->meta == M_END) {
891+
// emit an empty body token when there is no body
890892
emitted.type = HS_TOK_BODY;
891893
}
892894
break;
@@ -953,16 +955,14 @@ http_token_t http_parse(http_parser_t* parser, hs_stream_t* stream) {
953955
while (hs_stream_next(stream, &c)) {
954956
int type = c < 0 ? HS_ETC : hs_ctype[(int)c];
955957
int to = hs_transitions[parser->state * HS_CHAR_TYPE_LEN + type];
956-
if (parser->meta == M_ZER && parser->state == HN && to == BD) {
957-
to = CS;
958-
}
958+
to = parser->meta == M_ZER && to == BD ? CS : to;
959959
int from = parser->state;
960960
parser->state = to;
961961
http_token_t emitted = hs_transition_action(parser, stream, c, from, to);
962962
hs_stream_consume(stream);
963963
if (emitted.type != HS_TOK_NONE) return emitted;
964964
}
965-
if (parser->state == CB) hs_stream_shift(stream);
965+
if (parser->state >= CS && parser->state <= C2) hs_stream_shift(stream);
966966
token = hs_meta_emit(parser);
967967
http_token_t current = hs_stream_current_token(stream);
968968
if (
@@ -1046,8 +1046,6 @@ void hs_reset_timeout(http_request_t* request, int time) {
10461046
request->timeout = time;
10471047
}
10481048

1049-
void hs_read_and_process_request(http_request_t* request);
1050-
10511049
void hs_write_response(http_request_t* request) {
10521050
if (!hs_write_client_socket(request)) {
10531051
HTTP_FLAG_SET(request->flags, HTTP_END_SESSION);

0 commit comments

Comments
 (0)