|
| 1 | +#ifndef AWS_HTTP_H2_STREAM_H |
| 2 | +#define AWS_HTTP_H2_STREAM_H |
| 3 | + |
| 4 | +/* |
| 5 | + * Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 6 | + * |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"). |
| 8 | + * You may not use this file except in compliance with the License. |
| 9 | + * A copy of the License is located at |
| 10 | + * |
| 11 | + * http://aws.amazon.com/apache2.0 |
| 12 | + * |
| 13 | + * or in the "license" file accompanying this file. This file is distributed |
| 14 | + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 15 | + * express or implied. See the License for the specific language governing |
| 16 | + * permissions and limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +#include <aws/http/private/h2_frames.h> |
| 20 | +#include <aws/http/private/request_response_impl.h> |
| 21 | + |
| 22 | +#include <aws/common/mutex.h> |
| 23 | + |
| 24 | +enum aws_h2_stream_state { |
| 25 | + AWS_H2_STREAM_STATE_IDLE, |
| 26 | + AWS_H2_STREAM_STATE_RESERVED_LOCAL, |
| 27 | + AWS_H2_STREAM_STATE_RESERVED_REMOTE, |
| 28 | + AWS_H2_STREAM_STATE_OPEN, |
| 29 | + AWS_H2_STREAM_STATE_HALF_CLOSED_LOCAL, |
| 30 | + AWS_H2_STREAM_STATE_HALF_CLOSED_REMOTE, |
| 31 | + AWS_H2_STREAM_STATE_CLOSED, |
| 32 | + |
| 33 | + AWS_H2_STREAM_STATE_COUNT, |
| 34 | +}; |
| 35 | + |
| 36 | +struct aws_h2_stream { |
| 37 | + struct aws_http_stream base; |
| 38 | + |
| 39 | + const uint32_t id; |
| 40 | + |
| 41 | + /* Only the event-loop thread may touch this data */ |
| 42 | + struct { |
| 43 | + bool expects_continuation; |
| 44 | + enum aws_h2_stream_state state; |
| 45 | + uint64_t window_size; /* #TODO try to figure out how this actually works, and then implement it */ |
| 46 | + } thread_data; |
| 47 | + |
| 48 | + /* Any thread may touch this data, but the lock must be held */ |
| 49 | + struct { |
| 50 | + struct aws_mutex lock; |
| 51 | + |
| 52 | + } synced_data; |
| 53 | +}; |
| 54 | + |
| 55 | +struct aws_h2_stream; |
| 56 | + |
| 57 | +AWS_EXTERN_C_BEGIN |
| 58 | + |
| 59 | +AWS_HTTP_API |
| 60 | +const char *aws_h2_stream_state_to_str(enum aws_h2_stream_state state); |
| 61 | + |
| 62 | +AWS_HTTP_API |
| 63 | +struct aws_h2_stream *aws_h1_stream_new_request( |
| 64 | + struct aws_http_connection *client_connection, |
| 65 | + const struct aws_http_make_request_options *options); |
| 66 | + |
| 67 | +AWS_HTTP_API |
| 68 | +int aws_h2_stream_handle_frame(struct aws_h2_stream *stream, struct aws_h2_frame_decoder *decoder); |
| 69 | + |
| 70 | +AWS_EXTERN_C_END |
| 71 | + |
| 72 | +#endif /* AWS_HTTP_H2_STREAM_H */ |
0 commit comments