Skip to content

Commit

Permalink
Fix reading of POST bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
lpereira committed May 25, 2024
1 parent 1eeecb7 commit e1442a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/lib/lwan-request.c
Original file line number Diff line number Diff line change
Expand Up @@ -1288,8 +1288,10 @@ get_remaining_body_data_length(struct lwan_request *request,
return HTTP_BAD_REQUEST;
if (UNLIKELY((size_t)parsed_size >= max_size))
return HTTP_TOO_LARGE;
if (UNLIKELY(!parsed_size))
if (UNLIKELY(!parsed_size)) {
*total = *have = 0;
return HTTP_OK;
}

*total = (size_t)parsed_size;

Expand Down Expand Up @@ -1336,7 +1338,7 @@ static int read_body_data(struct lwan_request *request)

status =
get_remaining_body_data_length(request, max_data_size, &total, &have);
if (status != HTTP_PARTIAL_CONTENT)
if (status != HTTP_PARTIAL_CONTENT && status != HTTP_OK)
return -(int)status;

new_buffer =
Expand Down
3 changes: 2 additions & 1 deletion src/lib/lwan.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ void lwan_detect_url_map(struct lwan *l)
iter->name, iter->route);

const struct lwan_url_map map = {.prefix = iter->route,
.handler = iter->handler};
.handler = iter->handler,
.flags = HANDLER_PARSE_MASK};
register_url_map(l, &map);
}
}
Expand Down

0 comments on commit e1442a5

Please sign in to comment.