Debian Codegraph @

crt/aws-c-s3/include/aws/s3/private/s3_request_messages.h

raw symbols SCIP
1 #ifndef AWS_S3_REQUEST_MESSAGES_H
2 #define AWS_S3_REQUEST_MESSAGES_H
3
4 /**
5 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6 * SPDX-License-Identifier: Apache-2.0.
7 */
8 #include "aws/s3/s3.h"
9 #include "aws/s3/s3_client.h"
10 #include <inttypes.h>
11 #include <stdbool.h>
12 #include <stddef.h>
13
14 struct aws_allocator;
15 struct aws_http_message;
16 struct aws_byte_buf;
17 struct aws_byte_cursor;
18 struct aws_string;
19 struct aws_array_list;
20 struct aws_s3_meta_request_checksum_config_storage;
21 struct aws_s3_upload_request_checksum_context;
22
23 AWS_EXTERN_C_BEGIN
24
25 /* Copy message (but not the body) and retain all headers */
26 AWS_S3_API
27 struct aws_http_message *aws_s3_message_util_copy_http_message_no_body_all_headers(
28 struct aws_allocator *allocator,
29 struct aws_http_message *message);
30
31 /* Copy message (but not the body) and exclude specific headers.
32 * exclude_x_amz_meta controls whether S3 user metadata headers (prefixed with "x-amz-meta) are excluded.*/
33 AWS_S3_API
34 struct aws_http_message *aws_s3_message_util_copy_http_message_no_body_filter_headers(
35 struct aws_allocator *allocator,
36 struct aws_http_message *message,
37 const struct aws_byte_cursor *excluded_headers_arrays,
38 size_t excluded_headers_size,
39 bool exclude_x_amz_meta,
40 bool exclude_x_checksum);
41
42 /* Copy headers from one message to the other and exclude specific headers.
43 * exclude_x_amz_meta controls whether S3 user metadata headers (prefixed with "x-amz-meta) are excluded.*/
44 AWS_S3_API
45 void aws_s3_message_util_copy_headers(
46 struct aws_http_message *source_message,
47 struct aws_http_message *dest_message,
48 const struct aws_byte_cursor *excluded_headers_arrays,
49 size_t excluded_headers_size,
50 bool exclude_x_amz_meta,
51 bool exclude_x_checksum);
52
53 AWS_S3_API
54 struct aws_input_stream *aws_s3_message_util_assign_body(
55 struct aws_allocator *allocator,
56 struct aws_byte_buf *byte_buf,
57 struct aws_input_stream *stream,
58 struct aws_http_message *out_message,
59 struct aws_s3_upload_request_checksum_context *checksum_context);
60
61 /* Create an HTTP request for an S3 Ranged Get Object Request, using the given request as a basis */
62 AWS_S3_API
63 struct aws_http_message *aws_s3_ranged_get_object_message_new(
64 struct aws_allocator *allocator,
65 struct aws_http_message *base_message,
66 uint64_t range_start,
67 uint64_t range_end);
68
69 AWS_S3_API
70 int aws_s3_message_util_set_multipart_request_path(
71 struct aws_allocator *allocator,
72 const struct aws_string *upload_id,
73 uint32_t part_number,
74 bool append_uploads_suffix,
75 struct aws_http_message *message);
76
77 /* Create an HTTP request for an S3 Create-Multipart-Upload request. */
78 AWS_S3_API
79 struct aws_http_message *aws_s3_create_multipart_upload_message_new(
80 struct aws_allocator *allocator,
81 struct aws_http_message *base_message,
82 const struct aws_s3_meta_request_checksum_config_storage *checksum_config);
83
84 /* Create an HTTP request for an S3 Put Object request, using the original request as a basis. Creates and assigns a
85 * body stream using the passed in buffer. If multipart is not needed, part number and upload_id can be 0 and NULL,
86 * respectively. */
87 AWS_S3_API
88 struct aws_http_message *aws_s3_upload_part_message_new(
89 struct aws_allocator *allocator,
90 struct aws_http_message *base_message,
91 struct aws_byte_buf *buffer,
92 uint32_t part_number,
93 const struct aws_string *upload_id,
94 bool should_compute_content_md5,
95 struct aws_s3_upload_request_checksum_context *checksum_context);
96
97 /* Same as `aws_s3_upload_part_message_new`, but instead of taking the loaded buffer, taking the input stream for
98 * streaming I/O. */
99 AWS_S3_API
100 struct aws_http_message *aws_s3_upload_part_message_new_streaming(
101 struct aws_allocator *allocator,
102 struct aws_http_message *base_message,
103 struct aws_input_stream *input_stream,
104 uint32_t part_number,
105 const struct aws_string *upload_id,
106 bool should_compute_content_md5,
107 struct aws_s3_upload_request_checksum_context *checksum_context);
108
109 /* Create an HTTP request for an S3 UploadPartCopy request, using the original request as a basis.
110 * If multipart is not needed, part number and upload_id can be 0 and NULL,
111 * respectively. */
112 AWS_S3_API
113 struct aws_http_message *aws_s3_upload_part_copy_message_new(
114 struct aws_allocator *allocator,
115 struct aws_http_message *base_message,
116 struct aws_byte_buf *buffer,
117 uint32_t part_number,
118 uint64_t range_start,
119 uint64_t range_end,
120 const struct aws_string *upload_id,
121 bool should_compute_content_md5);
122
123 /* Create an HTTP request for an S3 Complete-Multipart-Upload request. Creates the necessary XML payload using the
124 * passed in array list of `struct aws_s3_mpu_part_info *`. Buffer passed in will be used to store
125 * said XML payload, which will be used as the body. The x-amz-mp-object-size header is taken from object_size; pass
126 * the known total object size, or 0 to omit the header (e.g. a streaming upload of unknown length). */
127 AWS_S3_API
128 struct aws_http_message *aws_s3_complete_multipart_message_with_object_size_new(
129 struct aws_allocator *allocator,
130 struct aws_http_message *base_message,
131 struct aws_byte_buf *body_buffer,
132 const struct aws_string *upload_id,
133 const struct aws_array_list *parts,
134 const struct aws_s3_meta_request_checksum_config_storage *checksum_config,
135 uint64_t object_size);
136
137 /* Convenience wrapper over aws_s3_complete_multipart_message_with_object_size_new() that derives the object size from
138 * base_message's Content-Length (0 if absent/unparseable). Suitable for the multipart upload path, where the base PUT
139 * carries the full object length; the copy path must call the _with_object_size_ variant directly because its base
140 * CopyObject is bodyless. */
141 AWS_S3_API
142 struct aws_http_message *aws_s3_complete_multipart_message_new(
143 struct aws_allocator *allocator,
144 struct aws_http_message *base_message,
145 struct aws_byte_buf *body_buffer,
146 const struct aws_string *upload_id,
147 const struct aws_array_list *parts,
148 const struct aws_s3_meta_request_checksum_config_storage *checksum_config);
149
150 AWS_S3_API
151 struct aws_http_message *aws_s3_abort_multipart_upload_message_new(
152 struct aws_allocator *allocator,
153 struct aws_http_message *base_message,
154 const struct aws_string *upload_id);
155
156 /* Creates a HEAD GetObject request to get the size of the specified object. */
157 AWS_S3_API
158 struct aws_http_message *aws_s3_get_object_size_message_new(
159 struct aws_allocator *allocator,
160 struct aws_http_message *base_message,
161 struct aws_byte_cursor source_bucket,
162 struct aws_byte_cursor source_key);
163
164 /* Creates a HEAD GetObject sub-request to get the size of the source object of a Copy meta request. */
165 AWS_S3_API
166 struct aws_http_message *aws_s3_get_source_object_size_message_new(
167 struct aws_allocator *allocator,
168 struct aws_http_message *base_message,
169 struct aws_uri *source_uri);
170
171 /* Add content-md5 header to the http message passed in. The MD5 will be computed from the input_buf */
172 AWS_S3_API
173 int aws_s3_message_util_add_content_md5_header(
174 struct aws_allocator *allocator,
175 struct aws_byte_buf *input_buf,
176 struct aws_http_message *message);
177
178 AWS_S3_API
179 extern const struct aws_byte_cursor g_s3_create_multipart_upload_excluded_headers[];
180
181 AWS_S3_API
182 extern const size_t g_s3_create_multipart_upload_excluded_headers_count;
183
184 AWS_S3_API
185 extern const struct aws_byte_cursor g_s3_upload_part_excluded_headers[];
186
187 AWS_S3_API
188 extern const size_t g_s3_upload_part_excluded_headers_count;
189
190 AWS_S3_API
191 extern const struct aws_byte_cursor g_s3_complete_multipart_upload_excluded_headers[];
192
193 AWS_S3_API
194 extern const size_t g_s3_complete_multipart_upload_excluded_headers_count;
195
196 AWS_S3_API
197 extern const struct aws_byte_cursor g_s3_abort_multipart_upload_excluded_headers[];
198
199 AWS_S3_API
200 extern const size_t g_s3_create_session_allowed_headers_count;
201
202 AWS_S3_API
203 extern const struct aws_byte_cursor g_s3_create_session_allowed_headers[];
204
205 AWS_S3_API
206 extern const size_t g_s3_abort_multipart_upload_excluded_headers_count;
207
208 AWS_S3_API
209 extern const struct aws_byte_cursor g_s3_list_parts_excluded_headers[];
210
211 AWS_S3_API extern const size_t g_s3_list_parts_excluded_headers_count;
212
213 AWS_S3_API
214 extern const struct aws_byte_cursor g_s3_list_parts_with_checksum_excluded_headers[];
215
216 AWS_S3_API
217 extern const size_t g_s3_list_parts_with_checksum_excluded_headers_count;
218
219 AWS_EXTERN_C_END
220
221 #endif /* AWS_S3_REQUEST_H */