Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions httpserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ void hs_delete_events(struct http_request_s* request);
void hs_add_events(struct http_request_s* request);
void hs_add_write_event(struct http_request_s* request);
void hs_process_tokens(http_request_t* request);
void hs_read_and_process_request(http_request_t* request);

#ifdef KQUEUE

Expand Down Expand Up @@ -610,7 +611,7 @@ char const * hs_status_text[] = {
};

static int const hs_transitions[] = {
// A-Z G-Z
// A-F G-Z
// spc \n \r : \t ; 0-9 a-f g-z tch vch etc
/* ST start */ BR, BR, BR, BR, BR, BR, BR, MT, MT, MT, BR, BR,
/* MT method */ MS, BR, BR, BR, BR, BR, MT, MT, MT, MT, BR, BR,
Expand Down Expand Up @@ -860,6 +861,7 @@ http_token_t hs_transition_action(
break;
case RR:
case HR:
// trigger meta end value on \r of request line and header
hs_trigger_meta(parser, HS_META_END_VALUE);
emitted = hs_stream_emit(stream);
break;
Expand All @@ -884,9 +886,9 @@ http_token_t hs_transition_action(
if (parser->meta == M_BIG || parser->meta == M_CHK) {
emitted.type = HS_TOK_BODY_STREAM;
}
//if (parser->meta == M_CHK) parser->state = CS;
hs_trigger_meta(parser, HS_META_END_HEADERS);
if (parser->meta == M_END) {
// emit an empty body token when there is no body
emitted.type = HS_TOK_BODY;
}
break;
Expand Down Expand Up @@ -953,9 +955,7 @@ http_token_t http_parse(http_parser_t* parser, hs_stream_t* stream) {
while (hs_stream_next(stream, &c)) {
int type = c < 0 ? HS_ETC : hs_ctype[(int)c];
int to = hs_transitions[parser->state * HS_CHAR_TYPE_LEN + type];
if (parser->meta == M_ZER && parser->state == HN && to == BD) {
to = CS;
}
to = parser->meta == M_ZER && to == BD ? CS : to;
int from = parser->state;
parser->state = to;
http_token_t emitted = hs_transition_action(parser, stream, c, from, to);
Expand Down Expand Up @@ -1046,8 +1046,6 @@ void hs_reset_timeout(http_request_t* request, int time) {
request->timeout = time;
}

void hs_read_and_process_request(http_request_t* request);

void hs_write_response(http_request_t* request) {
if (!hs_write_client_socket(request)) {
HTTP_FLAG_SET(request->flags, HTTP_END_SESSION);
Expand Down