Debian Codegraph @

crt/aws-c-http/tests/stream_test_helper.h

raw symbols SCIP
1 #ifndef AWS_HTTP_STREAM_TEST_HELPER_H
2 #define AWS_HTTP_STREAM_TEST_HELPER_H
3 /**
4 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * SPDX-License-Identifier: Apache-2.0.
6 */
7
8 #include <aws/http/request_response.h>
9
10 struct aws_http_connection;
11 struct aws_http_headers;
12 struct aws_http_message;
13 struct aws_http_stream;
14
15 struct client_stream_tester {
16 struct aws_allocator *alloc;
17 struct aws_http_stream *stream;
18
19 int response_status;
20
21 enum aws_http_header_block current_header_block;
22
23 /* Array of completed Informational (1xx) responses */
24 struct aws_http_message *info_responses[4];
25 size_t num_info_responses;
26
27 /* As Informational (1xx) headers arrive, they're buffered here.
28 * They copied into a new `info_responses` entry when the block is done */
29 struct aws_http_headers *current_info_headers;
30
31 /* Main header-block */
32 struct aws_http_headers *response_headers;
33 bool response_headers_done;
34
35 /* Trailing header-block */
36 struct aws_http_headers *response_trailer;
37 bool response_trailer_done;
38
39 struct aws_byte_buf response_body;
40
41 bool complete;
42 int on_complete_error_code;
43
44 /* Whether connection is open when on_complete fires */
45 bool on_complete_connection_is_open;
46 struct aws_http_stream_metrics metrics;
47
48 bool destroyed;
49
50 /* HTTP/2 only: Whether on_h2_remote_end_stream fired */
51 bool on_h2_remote_end_stream_invoked;
52 };
53
54 struct client_stream_tester_options {
55 struct aws_http_message *request;
56 struct aws_http_connection *connection;
57 bool http2_manual_write;
58 bool use_manual_data_writes;
59 /* Optional: pointer to bool to track if on_h2_remote_end_stream fires */
60 bool *on_h2_remote_end_stream;
61 };
62
63 int client_stream_tester_init(
64 struct client_stream_tester *tester,
65 struct aws_allocator *alloc,
66 const struct client_stream_tester_options *options);
67
68 void client_stream_tester_clean_up(struct client_stream_tester *tester);
69
70 #endif /* AWS_HTTP_STREAM_TEST_HELPER_H */