142 142 | let headers_to_check = request.headers().iter().filter_map(|(name, _val)| {
|
143 143 | if name.starts_with("x-amz-checksum-") {
|
144 144 | Some(name)
|
145 145 | } else {
|
146 146 | None
|
147 147 | }
|
148 148 | });
|
149 149 | for algo_header in headers_to_check {
|
150 150 | if request.headers().get(algo_header).is_some() {
|
151 151 | user_set_checksum_value = true;
|
152 152 | }
|
153 153 | }
|
154 154 |
|
155 155 | // We check if the user set the checksum algo manually
|
156 156 | let user_set_checksum_algo = request.headers()
|
157 157 | .get("x-amz-sdk-checksum-algorithm")
|
158 158 | .is_some();
|
159 159 |
|
160 160 | // This value is set by the user on the SdkConfig to indicate their preference
|
161 161 | let request_checksum_calculation = cfg
|
162 162 | .load::<::aws_smithy_types::checksum_config::RequestChecksumCalculation>()
|
163 163 | .unwrap_or(&::aws_smithy_types::checksum_config::RequestChecksumCalculation::WhenSupported);
|
164 164 |
|
165 165 | // From the httpChecksum trait
|
166 166 | let http_checksum_required = true;
|
167 167 |
|
168 168 | let is_presigned_req = cfg.load::<crate::presigning::PresigningMarker>().is_some();
|
169 169 |
|
170 170 | // If the request is presigned we do not set a default.
|
171 171 | // If the RequestChecksumCalculation is WhenSupported and the user has not set a checksum value or algo
|
172 - | // we default to Crc32. If it is WhenRequired and a checksum is required by the trait and the user has not
|
172 + | // we set the default. If it is WhenRequired and a checksum is required by the trait and the user has not
|
173 173 | // set a checksum value or algo we also set the default. In all other cases we do nothing.
|
174 174 | match (
|
175 175 | request_checksum_calculation,
|
176 176 | http_checksum_required,
|
177 177 | user_set_checksum_value,
|
178 178 | user_set_checksum_algo,
|
179 179 | is_presigned_req,
|
180 180 | ) {
|
181 181 | (_, _, _, _, true) => {}
|
182 182 | (::aws_smithy_types::checksum_config::RequestChecksumCalculation::WhenSupported, _, false, false, _)
|
183 183 | | (::aws_smithy_types::checksum_config::RequestChecksumCalculation::WhenRequired, true, false, false, _) => {
|
184 184 | request.headers_mut().insert("x-amz-sdk-checksum-algorithm", "CRC32");
|
185 185 | }
|
186 186 | _ => {},
|
187 187 | }
|
188 188 |
|
189 189 | // We return a bool indicating if the user did set the checksum value, if they did
|
190 190 | // we can short circuit and exit the interceptor early.
|
191 191 | Ok(user_set_checksum_value)
|
192 192 | }
|
193 193 | ))
|
194 194 | .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<crate::operation::put_public_access_block::PutPublicAccessBlockError>::new())
|
195 195 | .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<crate::operation::put_public_access_block::PutPublicAccessBlockError>::new())
|
196 196 | .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<crate::operation::put_public_access_block::PutPublicAccessBlockError>::builder().transient_errors({
|
197 197 | let mut transient_errors: Vec<&'static str> = ::aws_runtime::retries::classifiers::TRANSIENT_ERRORS.into();
|
198 198 | transient_errors.push("InternalError");
|
199 199 | ::std::borrow::Cow::Owned(transient_errors)
|
200 200 | }).build());
|
201 201 |
|
202 202 | ::std::borrow::Cow::Owned(rcb)
|