Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b756139
Start implementing streams
dislogical Jun 25, 2019
9d3af3f
Progress
dislogical Jun 27, 2019
ed1bccd
Day 3, still no one has figured out I have no idea what I'm doing
dislogical Jun 27, 2019
b27a845
Error handling and logging
dislogical Jul 3, 2019
1487f94
Missed h1 -> h2 renames
dislogical Jul 4, 2019
d8b677b
Use aws_http_stream_destroy instead of h2 specific function
dislogical Jul 15, 2019
52582fd
Delete h2 connection since it's not good
dislogical Jul 15, 2019
b2455bf
Mike's LOGF idea
dislogical Jul 15, 2019
0c0b924
h2 stream interface updates
dislogical Oct 1, 2019
caebfbf
Initial h2_connection
dislogical Oct 4, 2019
4213cfe
Implement simple get_next_stream_id
dislogical Oct 4, 2019
e84ace9
Add simple h2_connection setup
dislogical Oct 4, 2019
6d392e1
Add h2_decoder framework
dislogical Oct 4, 2019
0b4ac9d
Move h1 connection functions to h1_connection.h
dislogical Oct 4, 2019
8f729fe
Disable H2 support (for now)
dislogical Oct 4, 2019
f422ab5
Decoder use calloc
dislogical Oct 4, 2019
6150037
CI Fixes
dislogical Oct 4, 2019
8ec1829
Remove unnecessary error info for end of range
dislogical Oct 4, 2019
0b58c48
Sorry mr MSVC
dislogical Oct 4, 2019
aa6b076
Add overflow detection to next_stream_id
dislogical Oct 4, 2019
1143df1
Anther MSVC fix
dislogical Oct 4, 2019
4b7f101
Merge branch 'master' into h2b
dislogical Oct 7, 2019
5d35702
PR feedback
dislogical Oct 7, 2019
aac3f5a
Replace AWS_ERROR_HTTP_PARSE with PROTOCOL_ERROR
dislogical Oct 14, 2019
3922065
Split thread and synced data
dislogical Oct 14, 2019
c0fbdd1
next_stream_id, and sync it, correct it to 31 bits
dislogical Oct 14, 2019
de38c3d
lol oops
dislogical Oct 14, 2019
34bc873
Return UNKNOWN for invalid enum value
dislogical Oct 14, 2019
620e897
What even is a peer
dislogical Oct 14, 2019
6ac0b43
sacrifice a goat to the CI gods
dislogical Oct 14, 2019
9701bab
CI fixes, and remove bad window updater
dislogical Oct 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/aws/http/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

enum aws_http_errors {
AWS_ERROR_HTTP_UNKNOWN = 0x0800,
AWS_ERROR_HTTP_PARSE,
AWS_ERROR_HTTP_INVALID_HEADER_FIELD,
AWS_ERROR_HTTP_INVALID_HEADER_NAME,
AWS_ERROR_HTTP_INVALID_HEADER_VALUE,
Expand All @@ -47,6 +46,8 @@ enum aws_http_errors {
AWS_ERROR_HTTP_SERVER_CLOSED,
AWS_ERROR_HTTP_PROXY_TLS_CONNECT_FAILED,
AWS_ERROR_HTTP_CONNECTION_MANAGER_SHUTTING_DOWN,
AWS_ERROR_HTTP_PROTOCOL_ERROR,
AWS_ERROR_HTTP_STREAM_CLOSED,

AWS_ERROR_HTTP_END_RANGE = 0x0C00,
};
Expand Down
10 changes: 0 additions & 10 deletions include/aws/http/private/connection_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,6 @@ struct aws_http_client_bootstrap {

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_HTTP_API
void aws_http_connection_set_system_vtable(const struct aws_http_connection_system_vtable *system_vtable);

Expand Down
35 changes: 35 additions & 0 deletions include/aws/http/private/h1_connection.h
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 */
58 changes: 58 additions & 0 deletions include/aws/http/private/h2_connection.h
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 */
42 changes: 42 additions & 0 deletions include/aws/http/private/h2_decoder.h
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 */
3 changes: 3 additions & 0 deletions include/aws/http/private/h2_frames.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ struct aws_h2_frame_decoder {

AWS_EXTERN_C_BEGIN

AWS_HTTP_API
const char *aws_h2_frame_type_to_str(enum aws_h2_frame_type type);

/* Internal methods exposed for testing purposes only */
AWS_HTTP_API
int aws_h2_frame_header_block_init(struct aws_h2_frame_header_block *header_block, struct aws_allocator *allocator);
Expand Down
72 changes: 72 additions & 0 deletions include/aws/http/private/h2_stream.h
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 */
11 changes: 10 additions & 1 deletion source/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
* permissions and limitations under the License.
*/

#include <aws/http/private/connection_impl.h>
#include <aws/http/private/h1_connection.h>
#include <aws/http/private/h2_connection.h>
#include <aws/http/private/proxy_impl.h>

#include <aws/common/hash_table.h>
Expand Down Expand Up @@ -147,6 +148,14 @@ static struct aws_http_connection *s_connection_new(
connection = aws_http_connection_new_http1_1_client(alloc, initial_window_size);
}
break;
case AWS_HTTP_VERSION_2:
AWS_FATAL_ASSERT(false && "H2 is not currently supported"); /* lol nice try */
if (is_server) {
connection = aws_http_connection_new_http2_server(alloc, initial_window_size);
} else {
connection = aws_http_connection_new_http2_client(alloc, initial_window_size);
}
break;
default:
AWS_LOGF_ERROR(
AWS_LS_HTTP_CONNECTION,
Expand Down
Loading