Debian Codegraph @

crt/aws-c-http/include/aws/http/private/request_response_impl.h

raw symbols SCIP
1 #ifndef AWS_HTTP_REQUEST_RESPONSE_IMPL_H
2 #define AWS_HTTP_REQUEST_RESPONSE_IMPL_H
3
4 /**
5 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6 * SPDX-License-Identifier: Apache-2.0.
7 */
8
9 #include <aws/common/task_scheduler.h>
10 #include <aws/http/request_response.h>
11
12 #include <aws/http/private/http_impl.h>
13
14 #include <aws/common/atomics.h>
15
16 struct aws_http_stream_vtable {
17 void (*destroy)(struct aws_http_stream *stream);
18 void (*update_window)(struct aws_http_stream *stream, size_t increment_size);
19 int (*activate)(struct aws_http_stream *stream);
20 void (*cancel)(struct aws_http_stream *stream, int error_code);
21
22 int (*http1_write_chunk)(struct aws_http_stream *http1_stream, const struct aws_http1_chunk_options *options);
23 int (*http1_add_trailer)(struct aws_http_stream *http1_stream, const struct aws_http_headers *trailing_headers);
24
25 int (*http2_reset_stream)(struct aws_http_stream *http2_stream, uint32_t http2_error);
26 int (*http2_get_received_error_code)(struct aws_http_stream *http2_stream, uint32_t *http2_error);
27 int (*http2_get_sent_error_code)(struct aws_http_stream *http2_stream, uint32_t *http2_error);
28 int (*write_data)(struct aws_http_stream *stream, const struct aws_http_stream_write_data_options *options);
29 };
30
31 /**
32 * Base class for streams.
33 * There are specific implementations for each HTTP version.
34 */
35 struct aws_http_stream {
36 const struct aws_http_stream_vtable *vtable;
37 struct aws_allocator *alloc;
38 struct aws_http_connection *owning_connection;
39
40 uint32_t id;
41
42 void *user_data;
43 aws_http_on_incoming_headers_fn *on_incoming_headers;
44 aws_http_on_incoming_header_block_done_fn *on_incoming_header_block_done;
45 aws_http_on_incoming_body_fn *on_incoming_body;
46 aws_http_on_stream_metrics_fn *on_metrics;
47 aws_http_on_stream_complete_fn *on_complete;
48 aws_http_on_stream_destroy_fn *on_destroy;
49
50 struct aws_atomic_var refcount;
51 enum aws_http_method request_method;
52 struct aws_http_stream_metrics metrics;
53
54 union {
55 struct aws_http_stream_client_data {
56 int response_status;
57 uint64_t response_first_byte_timeout_ms;
58 /* Using aws_task instead of aws_channel_task because, currently, channel-tasks can't be canceled.
59 * We only touch this from the connection's thread */
60 struct aws_task response_first_byte_timeout_task;
61 } client;
62 struct aws_http_stream_server_data {
63 struct aws_byte_cursor request_method_str;
64 struct aws_byte_cursor request_path;
65 aws_http_on_incoming_request_done_fn *on_request_done;
66 } server;
67 } client_or_server_data;
68
69 /* On client connections, `client_data` points to client_or_server_data.client and `server_data` is null.
70 * Opposite is true on server connections */
71 struct aws_http_stream_client_data *client_data;
72 struct aws_http_stream_server_data *server_data;
73 };
74
75 #endif /* AWS_HTTP_REQUEST_RESPONSE_IMPL_H */