Fix unhandled content issue

This commit is contained in:
Ilja Kartašov 2019-04-25 13:50:05 +02:00
parent 12be39c747
commit 2af6556748
2 changed files with 13 additions and 3 deletions

View File

@ -273,8 +273,9 @@ http_10_parse_header(char *data, int32_t *p_size, AislStream stream)
*p_size -= size;
return HTTP_PARSER_SUCCESS;
} else if (newline == key || (newline == key+1 && *key == '\r')) {
*p_size -= size;
return (aisl_stream_set_end_of_headers(stream) == 0) ?
HTTP_PARSER_READY : HTTP_PARSER_SUCCESS;
HTTP_PARSER_SUCCESS : HTTP_PARSER_READY;
}
return HTTP_PARSER_ERROR;
}
@ -283,7 +284,12 @@ http_10_parse_header(char *data, int32_t *p_size, AislStream stream)
ParserStatus
http_10_parse_body(char *data, int32_t *p_size, AislStream stream)
{
switch (aisl_stream_set_body(stream, data, *p_size)) {
int32_t size = *p_size;
if (!size)
return HTTP_PARSER_HUNGRY;
switch (aisl_stream_set_body(stream, data, size)) {
case 0:
return HTTP_PARSER_READY;
case -1:

View File

@ -168,6 +168,7 @@ aisl_stream_set_end_of_headers(AislStream stream)
} else {
result = 2;
}
return result;
}
@ -180,6 +181,8 @@ aisl_stream_set_body(AislStream stream, const char *data, int32_t size)
if (!(stream->content_length < size)) {
struct aisl_evt_input on_input;
stream->content_length -= size;
if (stream->content_length == 0) {
stream->state = AISL_STREAM_STATE_READY;
result = 0;
@ -358,6 +361,7 @@ aisl_response(AislStream stream, AislHttpResponse rs_code, uint64_t c_len)
return AISL_MALLOC_ERROR;
stream->head_offset = l;
stream->body_offset = l;
stream->state = AISL_STREAM_STATE_SEND_HEADER;
return AISL_SUCCESS;