Skip to content

Commit 43154e0

Browse files
Fixed error condition for when content-length=0 is set on a response or request that shouldn't allow content-length. (#153)
1 parent 3ae6418 commit 43154e0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

source/h1_decoder.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -526,15 +526,6 @@ static int s_linestate_header(struct aws_h1_decoder *decoder, struct aws_byte_cu
526526
return aws_raise_error(AWS_ERROR_HTTP_PROTOCOL_ERROR);
527527
}
528528

529-
if (decoder->body_headers_forbidden) {
530-
AWS_LOGF_ERROR(
531-
AWS_LS_HTTP_STREAM,
532-
"id=%p: Incoming headers for content-length received, but it is illegal for this message to have a "
533-
"body",
534-
decoder->logging_id);
535-
return aws_raise_error(AWS_ERROR_HTTP_PROTOCOL_ERROR);
536-
}
537-
538529
if (s_read_size(header.value_data, &decoder->content_length) != AWS_OP_SUCCESS) {
539530
AWS_LOGF_ERROR(
540531
AWS_LS_HTTP_STREAM,
@@ -547,6 +538,16 @@ static int s_linestate_header(struct aws_h1_decoder *decoder, struct aws_byte_cu
547538
AWS_BYTE_CURSOR_PRI(header.value_data));
548539
return AWS_OP_ERR;
549540
}
541+
542+
if (decoder->body_headers_forbidden && decoder->content_length != 0) {
543+
AWS_LOGF_ERROR(
544+
AWS_LS_HTTP_STREAM,
545+
"id=%p: Incoming headers for content-length received, but it is illegal for this message to have a "
546+
"body",
547+
decoder->logging_id);
548+
return aws_raise_error(AWS_ERROR_HTTP_PROTOCOL_ERROR);
549+
}
550+
550551
break;
551552

552553
case AWS_HTTP_HEADER_TRANSFER_ENCODING: {

0 commit comments

Comments
 (0)