-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy paths3_request_messages.h
192 lines (159 loc) · 6.73 KB
/
s3_request_messages.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#ifndef AWS_S3_REQUEST_MESSAGES_H
#define AWS_S3_REQUEST_MESSAGES_H
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include "aws/s3/s3.h"
#include "aws/s3/s3_client.h"
#include <inttypes.h>
#include <stdbool.h>
#include <stddef.h>
struct aws_allocator;
struct aws_http_message;
struct aws_byte_buf;
struct aws_byte_cursor;
struct aws_string;
struct aws_array_list;
struct checksum_config_storage;
AWS_EXTERN_C_BEGIN
/* Copy message (but not the body) and retain all headers */
AWS_S3_API
struct aws_http_message *aws_s3_message_util_copy_http_message_no_body_all_headers(
struct aws_allocator *allocator,
struct aws_http_message *message);
/* Copy message (but not the body) and exclude specific headers.
* exclude_x_amz_meta controls whether S3 user metadata headers (prefixed with "x-amz-meta) are excluded.*/
AWS_S3_API
struct aws_http_message *aws_s3_message_util_copy_http_message_no_body_filter_headers(
struct aws_allocator *allocator,
struct aws_http_message *message,
const struct aws_byte_cursor *excluded_headers_arrays,
size_t excluded_headers_size,
bool exclude_x_amz_meta);
/* Copy headers from one message to the other and exclude specific headers.
* exclude_x_amz_meta controls whether S3 user metadata headers (prefixed with "x-amz-meta) are excluded.*/
AWS_S3_API
void aws_s3_message_util_copy_headers(
struct aws_http_message *source_message,
struct aws_http_message *dest_message,
const struct aws_byte_cursor *excluded_headers_arrays,
size_t excluded_headers_size,
bool exclude_x_amz_meta);
AWS_S3_API
struct aws_input_stream *aws_s3_message_util_assign_body(
struct aws_allocator *allocator,
struct aws_byte_buf *byte_buf,
struct aws_http_message *out_message,
const struct checksum_config_storage *checksum_config,
struct aws_byte_buf *out_checksum);
/* Create an HTTP request for an S3 Ranged Get Object Request, using the given request as a basis */
AWS_S3_API
struct aws_http_message *aws_s3_ranged_get_object_message_new(
struct aws_allocator *allocator,
struct aws_http_message *base_message,
uint64_t range_start,
uint64_t range_end);
AWS_S3_API
int aws_s3_message_util_set_multipart_request_path(
struct aws_allocator *allocator,
const struct aws_string *upload_id,
uint32_t part_number,
bool append_uploads_suffix,
struct aws_http_message *message);
/* Create an HTTP request for an S3 Create-Multipart-Upload request. */
AWS_S3_API
struct aws_http_message *aws_s3_create_multipart_upload_message_new(
struct aws_allocator *allocator,
struct aws_http_message *base_message,
const struct checksum_config_storage *checksum_config);
/* Create an HTTP request for an S3 Put Object request, using the original request as a basis. Creates and assigns a
* body stream using the passed in buffer. If multipart is not needed, part number and upload_id can be 0 and NULL,
* respectively. */
AWS_S3_API
struct aws_http_message *aws_s3_upload_part_message_new(
struct aws_allocator *allocator,
struct aws_http_message *base_message,
struct aws_byte_buf *buffer,
uint32_t part_number,
const struct aws_string *upload_id,
bool should_compute_content_md5,
const struct checksum_config_storage *checksum_config,
struct aws_byte_buf *encoded_checksum_output);
/* Create an HTTP request for an S3 UploadPartCopy request, using the original request as a basis.
* If multipart is not needed, part number and upload_id can be 0 and NULL,
* respectively. */
AWS_S3_API
struct aws_http_message *aws_s3_upload_part_copy_message_new(
struct aws_allocator *allocator,
struct aws_http_message *base_message,
struct aws_byte_buf *buffer,
uint32_t part_number,
uint64_t range_start,
uint64_t range_end,
const struct aws_string *upload_id,
bool should_compute_content_md5);
/* Create an HTTP request for an S3 Complete-Multipart-Upload request. Creates the necessary XML payload using the
* passed in array list of `struct aws_s3_mpu_part_info *`. Buffer passed in will be used to store
* said XML payload, which will be used as the body. */
AWS_S3_API
struct aws_http_message *aws_s3_complete_multipart_message_new(
struct aws_allocator *allocator,
struct aws_http_message *base_message,
struct aws_byte_buf *body_buffer,
const struct aws_string *upload_id,
const struct aws_array_list *parts,
const struct checksum_config_storage *checksum_config);
AWS_S3_API
struct aws_http_message *aws_s3_abort_multipart_upload_message_new(
struct aws_allocator *allocator,
struct aws_http_message *base_message,
const struct aws_string *upload_id);
/* Creates a HEAD GetObject request to get the size of the specified object. */
AWS_S3_API
struct aws_http_message *aws_s3_get_object_size_message_new(
struct aws_allocator *allocator,
struct aws_http_message *base_message,
struct aws_byte_cursor source_bucket,
struct aws_byte_cursor source_key);
/* Creates a HEAD GetObject sub-request to get the size of the source object of a Copy meta request. */
AWS_S3_API
struct aws_http_message *aws_s3_get_source_object_size_message_new(
struct aws_allocator *allocator,
struct aws_http_message *base_message,
struct aws_uri *source_uri);
/* Add content-md5 header to the http message passed in. The MD5 will be computed from the input_buf */
AWS_S3_API
int aws_s3_message_util_add_content_md5_header(
struct aws_allocator *allocator,
struct aws_byte_buf *input_buf,
struct aws_http_message *message);
AWS_S3_API
extern const struct aws_byte_cursor g_s3_create_multipart_upload_excluded_headers[];
AWS_S3_API
extern const size_t g_s3_create_multipart_upload_excluded_headers_count;
AWS_S3_API
extern const struct aws_byte_cursor g_s3_upload_part_excluded_headers[];
AWS_S3_API
extern const size_t g_s3_upload_part_excluded_headers_count;
AWS_S3_API
extern const struct aws_byte_cursor g_s3_complete_multipart_upload_excluded_headers[];
AWS_S3_API
extern const size_t g_s3_complete_multipart_upload_excluded_headers_count;
AWS_S3_API
extern const struct aws_byte_cursor g_s3_abort_multipart_upload_excluded_headers[];
AWS_S3_API
extern const size_t g_s3_create_session_allowed_headers_count;
AWS_S3_API
extern const struct aws_byte_cursor g_s3_create_session_allowed_headers[];
AWS_S3_API
extern const size_t g_s3_abort_multipart_upload_excluded_headers_count;
AWS_S3_API
extern const struct aws_byte_cursor g_s3_list_parts_excluded_headers[];
AWS_S3_API extern const size_t g_s3_list_parts_excluded_headers_count;
AWS_S3_API
extern const struct aws_byte_cursor g_s3_list_parts_with_checksum_excluded_headers[];
AWS_S3_API
extern const size_t g_s3_list_parts_with_checksum_excluded_headers_count;
AWS_EXTERN_C_END
#endif /* AWS_S3_REQUEST_H */