-
Notifications
You must be signed in to change notification settings - Fork 48
H2B: More incremental progres #149
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
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
b756139
Start implementing streams
dislogical 9d3af3f
Progress
dislogical ed1bccd
Day 3, still no one has figured out I have no idea what I'm doing
dislogical b27a845
Error handling and logging
dislogical 1487f94
Missed h1 -> h2 renames
dislogical d8b677b
Use aws_http_stream_destroy instead of h2 specific function
dislogical 52582fd
Delete h2 connection since it's not good
dislogical b2455bf
Mike's LOGF idea
dislogical 0c0b924
h2 stream interface updates
dislogical caebfbf
Initial h2_connection
dislogical 4213cfe
Implement simple get_next_stream_id
dislogical e84ace9
Add simple h2_connection setup
dislogical 6d392e1
Add h2_decoder framework
dislogical 0b4ac9d
Move h1 connection functions to h1_connection.h
dislogical 8f729fe
Disable H2 support (for now)
dislogical f422ab5
Decoder use calloc
dislogical 6150037
CI Fixes
dislogical 8ec1829
Remove unnecessary error info for end of range
dislogical 0b58c48
Sorry mr MSVC
dislogical aa6b076
Add overflow detection to next_stream_id
dislogical 1143df1
Anther MSVC fix
dislogical 4b7f101
Merge branch 'master' into h2b
dislogical 5d35702
PR feedback
dislogical aac3f5a
Replace AWS_ERROR_HTTP_PARSE with PROTOCOL_ERROR
dislogical 3922065
Split thread and synced data
dislogical c0fbdd1
next_stream_id, and sync it, correct it to 31 bits
dislogical de38c3d
lol oops
dislogical 34bc873
Return UNKNOWN for invalid enum value
dislogical 620e897
What even is a peer
dislogical 6ac0b43
sacrifice a goat to the CI gods
dislogical 9701bab
CI fixes, and remove bad window updater
dislogical File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #ifndef AWS_HTTP_H1_CONNECTION_H | ||
| #define AWS_HTTP_H1_CONNECTION_H | ||
|
|
||
| /* | ||
| * Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| #include <aws/http/private/connection_impl.h> | ||
|
|
||
| AWS_EXTERN_C_BEGIN | ||
|
|
||
| AWS_HTTP_API | ||
| struct aws_http_connection *aws_http_connection_new_http1_1_server( | ||
| struct aws_allocator *allocator, | ||
| size_t initial_window_size); | ||
|
|
||
| AWS_HTTP_API | ||
| struct aws_http_connection *aws_http_connection_new_http1_1_client( | ||
| struct aws_allocator *allocator, | ||
| size_t initial_window_size); | ||
|
|
||
| AWS_EXTERN_C_END | ||
|
|
||
| #endif /* AWS_HTTP_H1_CONNECTION_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #ifndef AWS_HTTP_H2_CONNECTION_H | ||
| #define AWS_HTTP_H2_CONNECTION_H | ||
|
|
||
| /* | ||
| * Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| #include <aws/common/atomics.h> | ||
| #include <aws/common/mutex.h> | ||
|
|
||
| #include <aws/http/private/connection_impl.h> | ||
|
|
||
| struct aws_h2_connection { | ||
| struct aws_http_connection base; | ||
|
|
||
| /* Only the event-loop thread may touch this data */ | ||
| struct { | ||
| struct aws_h2_decoder *decoder; | ||
| } thread_data; | ||
|
|
||
| /* Any thread may touch this data, but the lock must be held */ | ||
| struct { | ||
| struct aws_mutex lock; | ||
|
|
||
| /* Refers to the next stream id to vend */ | ||
| uint32_t next_stream_id; | ||
| } synced_data; | ||
| }; | ||
|
|
||
| AWS_EXTERN_C_BEGIN | ||
|
|
||
| AWS_HTTP_API | ||
| struct aws_http_connection *aws_http_connection_new_http2_server( | ||
| struct aws_allocator *allocator, | ||
| size_t initial_window_size); | ||
|
|
||
| AWS_HTTP_API | ||
| struct aws_http_connection *aws_http_connection_new_http2_client( | ||
| struct aws_allocator *allocator, | ||
| size_t initial_window_size); | ||
|
|
||
| AWS_HTTP_API | ||
| uint32_t aws_h2_connection_get_next_stream_id(struct aws_h2_connection *connection); | ||
|
|
||
| AWS_EXTERN_C_END | ||
|
|
||
| #endif /* AWS_HTTP_H2_CONNECTION_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #ifndef AWS_HTTP_H2_DECODER_H | ||
| #define AWS_HTTP_H2_DECODER_H | ||
|
|
||
| /* | ||
| * Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| #include <aws/http/private/http_impl.h> | ||
|
|
||
| /** | ||
| * Structure used to initialize an `aws_h2_decoder`. | ||
| */ | ||
| struct aws_h2_decoder_params { | ||
| struct aws_allocator *alloc; | ||
| void *user_data; | ||
| struct aws_http_decoder_vtable vtable; | ||
| }; | ||
|
|
||
| struct aws_h2_decoder; | ||
|
|
||
| AWS_EXTERN_C_BEGIN | ||
|
|
||
| AWS_HTTP_API struct aws_h2_decoder *aws_h2_decoder_new(struct aws_h2_decoder_params *params); | ||
| AWS_HTTP_API void aws_h2_decoder_destroy(struct aws_h2_decoder *decoder); | ||
| AWS_HTTP_API int aws_h2_decode(struct aws_h2_decoder *decoder, struct aws_byte_cursor *data); | ||
|
|
||
| AWS_HTTP_API void aws_h2_decoder_set_logging_id(struct aws_h2_decoder *decoder, void *id); | ||
|
|
||
| AWS_EXTERN_C_END | ||
|
|
||
| #endif /* AWS_HTTP_H2_DECODER_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #ifndef AWS_HTTP_H2_STREAM_H | ||
| #define AWS_HTTP_H2_STREAM_H | ||
|
|
||
| /* | ||
| * Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| #include <aws/http/private/h2_frames.h> | ||
| #include <aws/http/private/request_response_impl.h> | ||
|
|
||
| #include <aws/common/mutex.h> | ||
|
|
||
| enum aws_h2_stream_state { | ||
| AWS_H2_STREAM_STATE_IDLE, | ||
| AWS_H2_STREAM_STATE_RESERVED_LOCAL, | ||
| AWS_H2_STREAM_STATE_RESERVED_REMOTE, | ||
| AWS_H2_STREAM_STATE_OPEN, | ||
| AWS_H2_STREAM_STATE_HALF_CLOSED_LOCAL, | ||
| AWS_H2_STREAM_STATE_HALF_CLOSED_REMOTE, | ||
| AWS_H2_STREAM_STATE_CLOSED, | ||
|
|
||
| AWS_H2_STREAM_STATE_COUNT, | ||
| }; | ||
|
|
||
| struct aws_h2_stream { | ||
| struct aws_http_stream base; | ||
|
|
||
| const uint32_t id; | ||
|
|
||
| /* Only the event-loop thread may touch this data */ | ||
| struct { | ||
| bool expects_continuation; | ||
| enum aws_h2_stream_state state; | ||
| uint64_t window_size; /* #TODO try to figure out how this actually works, and then implement it */ | ||
| } thread_data; | ||
|
|
||
| /* Any thread may touch this data, but the lock must be held */ | ||
| struct { | ||
| struct aws_mutex lock; | ||
|
|
||
| } synced_data; | ||
| }; | ||
|
|
||
| struct aws_h2_stream; | ||
|
|
||
| AWS_EXTERN_C_BEGIN | ||
|
|
||
| AWS_HTTP_API | ||
| const char *aws_h2_stream_state_to_str(enum aws_h2_stream_state state); | ||
|
|
||
| AWS_HTTP_API | ||
| struct aws_h2_stream *aws_h1_stream_new_request( | ||
| struct aws_http_connection *client_connection, | ||
| const struct aws_http_make_request_options *options); | ||
|
|
||
| AWS_HTTP_API | ||
| int aws_h2_stream_handle_frame(struct aws_h2_stream *stream, struct aws_h2_frame_decoder *decoder); | ||
|
|
||
| AWS_EXTERN_C_END | ||
|
|
||
| #endif /* AWS_HTTP_H2_STREAM_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.