-
Notifications
You must be signed in to change notification settings - Fork 48
Address TODOs #383
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
base: main
Are you sure you want to change the base?
Address TODOs #383
Changes from 7 commits
355e6d8
875f015
5733ac0
e5ab40d
a4fbcbb
f42c4b8
b80322f
ee52c6a
85f362f
b63cc70
79b78d9
4beeba2
9275fff
f98f134
7b4bc8b
cce49e2
68dcf9b
052660c
480cd2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1159,6 +1159,42 @@ static struct aws_h2err s_flush_pseudoheaders(struct aws_h2_decoder *decoder) { | |
| if (has_request_pseudoheaders) { | ||
| /* Request header-block. */ | ||
| current_block->block_type = AWS_HTTP_HEADER_BLOCK_MAIN; | ||
| const struct aws_string *method_string = current_block->pseudoheader_values[PSEUDOHEADER_METHOD]; | ||
| const struct aws_string *scheme_string = current_block->pseudoheader_values[PSEUDOHEADER_SCHEME]; | ||
| const struct aws_string *authority_string = current_block->pseudoheader_values[PSEUDOHEADER_AUTHORITY]; | ||
| const struct aws_string *path_string = current_block->pseudoheader_values[PSEUDOHEADER_PATH]; | ||
|
|
||
| if (!method_string) { | ||
| DECODER_LOG(ERROR, decoder, "Request is missing :method."); | ||
| goto malformed; | ||
| } | ||
| if (!aws_strutil_is_http_token(aws_byte_cursor_from_string(method_string))) { | ||
| DECODER_LOG(ERROR, decoder, "Request method is invalid."); | ||
| DECODER_LOGF( | ||
| DEBUG, | ||
| decoder, | ||
| "Bad method is: '" PRInSTR "'", | ||
| AWS_BYTE_CURSOR_PRI(aws_byte_cursor_from_string(method_string))); | ||
| goto malformed; | ||
| } | ||
| if (aws_string_eq_c_str(method_string, "CONNECT")) { | ||
TingDaoK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
TingDaoK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (scheme_string || path_string) { | ||
| /* RFC-9113 8.5 The ":scheme" and ":path" pseudo-header fields MUST be omitted for CONNECT method */ | ||
| DECODER_LOG(ERROR, decoder, "CONNECT request has :path or :scheme that are must omitted."); | ||
|
||
| goto malformed; | ||
| } | ||
| if (!authority_string) { | ||
| DECODER_LOG(ERROR, decoder, "CONNECT request is missing :authority."); | ||
| goto malformed; | ||
| } | ||
| } else { | ||
| if (!scheme_string || !path_string) { | ||
| /* RFC-9113 8.3.1 All HTTP/2 requests MUST include exactly one valid value for the ":method", ":scheme", | ||
| * and ":path" pseudo-header fields, unless they are CONNECT requests */ | ||
| DECODER_LOG(ERROR, decoder, "Request missing :scheme or :path, which are required to have."); | ||
TingDaoK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| goto malformed; | ||
| } | ||
| } | ||
|
|
||
| } else if (has_response_pseudoheaders) { | ||
| /* Response header block. */ | ||
|
|
@@ -1202,9 +1238,6 @@ static struct aws_h2err s_flush_pseudoheaders(struct aws_h2_decoder *decoder) { | |
| current_block->block_type = AWS_HTTP_HEADER_BLOCK_TRAILING; | ||
| } | ||
|
|
||
| /* #TODO RFC-7540 8.1.2.3 & 8.3 Validate request has correct pseudoheaders. Note different rules for CONNECT */ | ||
| /* #TODO validate pseudoheader values. each one has its own special rules */ | ||
|
|
||
| /* Finally, deliver header-fields via callback */ | ||
| for (size_t i = 0; i < PSEUDOHEADER_COUNT; ++i) { | ||
| const struct aws_string *value_string = current_block->pseudoheader_values[i]; | ||
|
|
@@ -1256,6 +1289,21 @@ static struct aws_h2err s_process_header_field( | |
| goto malformed; | ||
| } | ||
|
|
||
| if (!aws_strutil_is_http_field_value(header_field->value)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just found a new TODO to add to our code. From RFC-9110:
I see the H1 encoder and decoder using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A field value MUST NOT start or end with an ASCII whitespace character (ASCII SP or HTAB, 0x20 or 0x09). here. So, I think we should not trim the white space for h2 |
||
| /** | ||
| * RFC9113 8.2.1 HTTP/2 implementations SHOULD validate field names and values, respectively, and treat | ||
| * messages that contain prohibited characters as malformed. | ||
| */ | ||
| DECODER_LOG(ERROR, decoder, "Invalid header field, bad value"); | ||
| DECODER_LOGF( | ||
| DEBUG, | ||
| decoder, | ||
| "Bad header field is: \"" PRInSTR ": " PRInSTR "\"", | ||
| AWS_BYTE_CURSOR_PRI(header_field->name), | ||
| AWS_BYTE_CURSOR_PRI(header_field->value)); | ||
| goto malformed; | ||
| } | ||
|
|
||
| enum aws_http_header_name name_enum = aws_http_lowercase_str_to_header_name(name); | ||
|
|
||
| bool is_pseudoheader = name.ptr[0] == ':'; | ||
|
|
@@ -1329,8 +1377,6 @@ static struct aws_h2err s_process_header_field( | |
| } | ||
| } | ||
|
|
||
| /* #TODO Validate characters used in header_field->value */ | ||
|
|
||
| switch (name_enum) { | ||
| case AWS_HTTP_HEADER_COOKIE: | ||
| /* for a header cookie, we will not fire callback until we concatenate them all, let's store it at the | ||
|
|
@@ -1363,7 +1409,18 @@ static struct aws_h2err s_process_header_field( | |
| AWS_BYTE_CURSOR_PRI(name)); | ||
| goto malformed; | ||
| } break; | ||
|
|
||
| case AWS_HTTP_HEADER_TE: { | ||
| /* the TE header field, which MAY be present in an HTTP/2 request; when it is, it MUST NOT contain any | ||
| * value other than "trailers" (RFC9113 8.2.2) */ | ||
| if (!aws_byte_cursor_eq_c_str(&header_field->value, "trailers")) { | ||
| DECODER_LOGF( | ||
| ERROR, | ||
| decoder, | ||
| "TE header has value:'" PRInSTR "', not allowed in HTTP/2", | ||
| AWS_BYTE_CURSOR_PRI(header_field->value)); | ||
| goto malformed; | ||
| } | ||
| } break; | ||
| case AWS_HTTP_HEADER_CONTENT_LENGTH: | ||
| if (current_block->body_headers_forbidden) { | ||
| /* The content-length are forbidden */ | ||
|
|
@@ -1529,12 +1586,6 @@ static struct aws_h2err s_state_fn_header_block_entry(struct aws_h2_decoder *dec | |
|
|
||
| /* Finished decoding HPACK entry! */ | ||
|
|
||
| /* #TODO Enforces dynamic table resize rules from RFC-7541 4.2 | ||
TingDaoK marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * If dynamic table size changed via SETTINGS frame, next header-block must start with DYNAMIC_TABLE_RESIZE entry. | ||
| * Is it illegal to receive a resize entry at other times? */ | ||
|
|
||
| /* #TODO The TE header field ... MUST NOT contain any value other than "trailers" */ | ||
|
|
||
| if (result.type == AWS_HPACK_DECODE_T_HEADER_FIELD) { | ||
| const struct aws_http_header *header_field = &result.data.header_field; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -504,8 +504,6 @@ static struct aws_h2_frame *s_frame_new_headers_or_push_promise( | |
| const struct aws_h2_frame_priority_settings *optional_priority, | ||
| uint32_t promised_stream_id) { | ||
|
|
||
| /* TODO: Host and ":authority" are no longer permitted to disagree. Should we enforce it here or sent it as | ||
| * requested, let the server side reject the request? */ | ||
| AWS_PRECONDITION(allocator); | ||
| AWS_PRECONDITION(frame_type == AWS_H2_FRAME_T_HEADERS || frame_type == AWS_H2_FRAME_T_PUSH_PROMISE); | ||
| AWS_PRECONDITION(headers); | ||
|
|
@@ -1228,7 +1226,8 @@ int aws_h2_encode_frame( | |
|
|
||
| void aws_h2_frame_encoder_set_setting_header_table_size(struct aws_h2_frame_encoder *encoder, uint32_t data) { | ||
| /* Setting for dynamic table size changed from peer, we will update the dynamic table size when we encoder the next | ||
| * header block */ | ||
| * header block. The spec requires us to update the table if the updated size is smaller than the current size, but | ||
| * we can still update it even if not */ | ||
| aws_hpack_set_max_table_size(encoder->hpack, data); | ||
| aws_hpack_set_protocol_max_size_setting(encoder->hpack, data); | ||
|
||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.