110 110 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
111 111 | B: 'static,
|
112 112 |
|
113 113 | B::Data: Send,
|
114 114 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
115 115 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
116 116 | {
|
117 117 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
118 118 | type Future = SparseNullsOperationInputFuture;
|
119 119 |
|
120 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
120 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
121 121 | let fut = async move {
|
122 122 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
123 123 | request.headers(),
|
124 124 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
125 125 | ) {
|
126 126 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
127 127 | }
|
128 128 | crate::protocol_serde::shape_sparse_nulls_operation::de_sparse_nulls_operation_http_request(request)
|
129 129 | .await
|
130 130 | };
|
131 131 | use ::futures_util::future::TryFutureExt;
|
132 132 | let fut = fut.map_err(
|
133 133 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
134 134 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
135 135 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
136 136 | e,
|
137 137 | )
|
138 138 | },
|
139 139 | );
|
140 140 | SparseNullsOperationInputFuture {
|
141 141 | inner: Box::pin(fut),
|
142 142 | }
|
143 143 | }
|
144 144 | }
|
145 145 | impl
|
146 146 | ::aws_smithy_http_server::response::IntoResponse<
|
147 147 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
148 148 | > for crate::output::SparseNullsOperationOutput
|
149 149 | {
|
150 150 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
151 151 | match crate::protocol_serde::shape_sparse_nulls_operation::ser_sparse_nulls_operation_http_response(self) {
|
152 152 | Ok(response) => response,
|
153 153 | Err(e) => {
|
154 154 | ::tracing::error!(error = %e, "failed to serialize response");
|
155 155 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
156 156 | }
|
157 157 | }
|
158 158 | }
|
159 159 | }
|
160 160 |
|
161 161 | #[allow(unreachable_code, unused_variables)]
|
162 162 | #[cfg(test)]
|
163 163 | mod sparse_nulls_operation_test {
|
164 164 |
|
165 165 | /// Serializes null values in maps
|
166 166 | /// Test ID: RpcV2CborSparseMapsSerializeNullValues
|
167 167 | #[::tokio::test]
|
168 168 | #[::tracing_test::traced_test]
|
169 169 | async fn rpc_v2_cbor_sparse_maps_serialize_null_values_request() {
|
170 170 | #[allow(unused_mut)]
|
171 - | let mut http_request = http::Request::builder()
|
171 + | let mut http_request = ::http_1x::Request::builder()
|
172 172 | .uri("/service/RpcV2Protocol/operation/SparseNullsOperation")
|
173 173 | .method("POST")
|
174 174 | .header("Accept", "application/cbor")
|
175 175 | .header("Content-Type", "application/cbor")
|
176 176 | .header("smithy-protocol", "rpc-v2-cbor")
|
177 - | .body(::aws_smithy_http_server::body::Body::from(
|
178 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
177 + | .body(::aws_smithy_http_server::body::boxed(
|
178 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
179 + | &::aws_smithy_protocol_test::decode_body_data(
|
179 180 | "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==".as_bytes(),
|
180 181 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
182 + | ),
|
181 183 | )),
|
182 184 | ))
|
183 185 | .unwrap();
|
184 186 | #[allow(unused_mut)]
|
185 187 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
186 188 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
187 - | let service =
|
188 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
189 + | let service = crate::service::RpcV2Protocol::builder::<
|
190 + | ::aws_smithy_http_server::body::BoxBody,
|
191 + | _,
|
192 + | _,
|
193 + | _,
|
194 + | >(config)
|
189 195 | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
190 196 | let sender = sender.clone();
|
191 197 | async move {
|
192 198 | let result = {
|
193 199 | let expected = crate::input::SparseNullsOperationInput {
|
194 200 | sparse_string_map: ::std::option::Option::Some({
|
195 201 | let mut ret = ::std::collections::HashMap::new();
|
196 202 | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
197 203 | ret
|
198 204 | }),
|
199 205 | sparse_string_list: ::std::option::Option::None,
|
200 206 | };
|
201 207 | ::pretty_assertions::assert_eq!(input, expected);
|
202 208 | let output = crate::output::SparseNullsOperationOutput {
|
203 209 | sparse_string_list: ::std::option::Option::None,
|
204 210 | sparse_string_map: ::std::option::Option::None,
|
205 211 | };
|
206 212 | output
|
207 213 | };
|
208 214 | sender.send(()).await.expect("receiver dropped early");
|
209 215 | result
|
210 216 | }
|
211 217 | })
|
212 218 | .build_unchecked();
|
213 219 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
214 220 | .await
|
215 221 | .expect("unable to make an HTTP request");
|
216 222 | assert!(
|
217 223 | receiver.recv().await.is_some(),
|
218 224 | "we expected operation handler to be invoked but it was not entered"
|
219 225 | );
|
220 226 | }
|
221 227 |
|
222 228 | /// Serializes null values in lists
|
223 229 | /// Test ID: RpcV2CborSparseListsSerializeNull
|
224 230 | #[::tokio::test]
|
225 231 | #[::tracing_test::traced_test]
|
226 232 | async fn rpc_v2_cbor_sparse_lists_serialize_null_request() {
|
227 233 | #[allow(unused_mut)]
|
228 - | let mut http_request = http::Request::builder()
|
234 + | let mut http_request = ::http_1x::Request::builder()
|
229 235 | .uri("/service/RpcV2Protocol/operation/SparseNullsOperation")
|
230 236 | .method("POST")
|
231 237 | .header("Accept", "application/cbor")
|
232 238 | .header("Content-Type", "application/cbor")
|
233 239 | .header("smithy-protocol", "rpc-v2-cbor")
|
234 - | .body(::aws_smithy_http_server::body::Body::from(
|
235 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
240 + | .body(::aws_smithy_http_server::body::boxed(
|
241 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
242 + | &::aws_smithy_protocol_test::decode_body_data(
|
236 243 | "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==".as_bytes(),
|
237 244 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
245 + | ),
|
238 246 | )),
|
239 247 | ))
|
240 248 | .unwrap();
|
241 249 | #[allow(unused_mut)]
|
242 250 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
243 251 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
244 - | let service =
|
245 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
252 + | let service = crate::service::RpcV2Protocol::builder::<
|
253 + | ::aws_smithy_http_server::body::BoxBody,
|
254 + | _,
|
255 + | _,
|
256 + | _,
|
257 + | >(config)
|
246 258 | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
247 259 | let sender = sender.clone();
|
248 260 | async move {
|
249 261 | let result = {
|
250 262 | let expected = crate::input::SparseNullsOperationInput {
|
251 263 | sparse_string_list: ::std::option::Option::Some(vec![
|
252 264 | ::std::option::Option::None,
|
253 265 | ]),
|
254 266 | sparse_string_map: ::std::option::Option::None,
|
255 267 | };
|
256 268 | ::pretty_assertions::assert_eq!(input, expected);
|
257 269 | let output = crate::output::SparseNullsOperationOutput {
|
258 270 | sparse_string_list: ::std::option::Option::None,
|
259 271 | sparse_string_map: ::std::option::Option::None,
|
260 272 | };
|
261 273 | output
|
262 274 | };
|
263 275 | sender.send(()).await.expect("receiver dropped early");
|
264 276 | result
|
265 277 | }
|
266 278 | })
|
267 279 | .build_unchecked();
|
268 280 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
269 281 | .await
|
270 282 | .expect("unable to make an HTTP request");
|
271 283 | assert!(
|
272 284 | receiver.recv().await.is_some(),
|
273 285 | "we expected operation handler to be invoked but it was not entered"
|
274 286 | );
|
275 287 | }
|
276 288 |
|
277 289 | /// Deserializes null values in maps
|
278 290 | /// Test ID: RpcV2CborSparseMapsDeserializeNullValues
|
279 291 | #[::tokio::test]
|
280 292 | #[::tracing_test::traced_test]
|
281 293 | async fn rpc_v2_cbor_sparse_maps_deserialize_null_values_response() {
|
282 294 | let output = crate::output::SparseNullsOperationOutput {
|
283 295 | sparse_string_map: ::std::option::Option::Some({
|
284 296 | let mut ret = ::std::collections::HashMap::new();
|
285 297 | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
286 298 | ret
|
287 299 | }),
|
288 300 | sparse_string_list: ::std::option::Option::None,
|
289 301 | };
|
290 302 | use ::aws_smithy_http_server::response::IntoResponse;
|
291 303 | let http_response = output.into_response();
|
292 304 | ::pretty_assertions::assert_eq!(
|
293 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
305 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
294 306 | http_response.status()
|
295 307 | );
|
296 308 | let expected_headers = [
|
297 309 | ("Content-Type", "application/cbor"),
|
298 310 | ("smithy-protocol", "rpc-v2-cbor"),
|
299 311 | ];
|
300 312 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
301 313 | http_response.headers(),
|
302 314 | expected_headers,
|
303 315 | ));
|
304 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
316 + | use ::http_body_util::BodyExt;
|
317 + | let body = http_response
|
318 + | .into_body()
|
319 + | .collect()
|
305 320 | .await
|
306 - | .expect("unable to extract body to bytes");
|
321 + | .expect("unable to collect body")
|
322 + | .to_bytes();
|
307 323 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
308 324 | &body,
|
309 325 | "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==",
|
310 326 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
311 327 | ));
|
312 328 | }
|
313 329 |
|
314 330 | /// Deserializes null values in lists
|
315 331 | /// Test ID: RpcV2CborSparseListsDeserializeNull
|
316 332 | #[::tokio::test]
|
317 333 | #[::tracing_test::traced_test]
|
318 334 | async fn rpc_v2_cbor_sparse_lists_deserialize_null_response() {
|
319 335 | let output = crate::output::SparseNullsOperationOutput {
|
320 336 | sparse_string_list: ::std::option::Option::Some(vec![::std::option::Option::None]),
|
321 337 | sparse_string_map: ::std::option::Option::None,
|
322 338 | };
|
323 339 | use ::aws_smithy_http_server::response::IntoResponse;
|
324 340 | let http_response = output.into_response();
|
325 341 | ::pretty_assertions::assert_eq!(
|
326 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
342 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
327 343 | http_response.status()
|
328 344 | );
|
329 345 | let expected_headers = [
|
330 346 | ("Content-Type", "application/cbor"),
|
331 347 | ("smithy-protocol", "rpc-v2-cbor"),
|
332 348 | ];
|
333 349 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
334 350 | http_response.headers(),
|
335 351 | expected_headers,
|
336 352 | ));
|
337 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
353 + | use ::http_body_util::BodyExt;
|
354 + | let body = http_response
|
355 + | .into_body()
|
356 + | .collect()
|
338 357 | .await
|
339 - | .expect("unable to extract body to bytes");
|
358 + | .expect("unable to collect body")
|
359 + | .to_bytes();
|
340 360 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
341 361 | &body,
|
342 362 | "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==",
|
343 363 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
344 364 | ));
|
345 365 | }
|
346 366 | }
|
347 367 |
|
348 368 | ::pin_project_lite::pin_project! {
|
349 369 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
350 370 | /// [`OperationWithDefaultsInput`](crate::input::OperationWithDefaultsInput) using modelled bindings.
|
351 371 | pub struct OperationWithDefaultsInputFuture {
|
352 372 | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OperationWithDefaultsInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
353 373 | }
|
354 374 | }
|
355 375 |
|
356 376 | impl std::future::Future for OperationWithDefaultsInputFuture {
|
357 377 | type Output = Result<
|
358 378 | crate::input::OperationWithDefaultsInput,
|
359 379 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
360 380 | >;
|
361 381 |
|
362 382 | fn poll(
|
363 383 | self: std::pin::Pin<&mut Self>,
|
364 384 | cx: &mut std::task::Context<'_>,
|
365 385 | ) -> std::task::Poll<Self::Output> {
|
366 386 | let this = self.project();
|
367 387 | this.inner.as_mut().poll(cx)
|
368 388 | }
|
369 389 | }
|
370 390 |
|
371 391 | impl<B>
|
372 392 | ::aws_smithy_http_server::request::FromRequest<
|
373 393 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
374 394 | B,
|
375 395 | > for crate::input::OperationWithDefaultsInput
|
376 396 | where
|
377 397 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
378 398 | B: 'static,
|
379 399 |
|
380 400 | B::Data: Send,
|
381 401 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
382 402 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
383 403 | {
|
384 404 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
385 405 | type Future = OperationWithDefaultsInputFuture;
|
386 406 |
|
387 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
407 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
388 408 | let fut = async move {
|
389 409 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
390 410 | request.headers(),
|
391 411 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
392 412 | ) {
|
393 413 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
394 414 | }
|
395 415 | crate::protocol_serde::shape_operation_with_defaults::de_operation_with_defaults_http_request(request)
|
396 416 | .await
|
397 417 | };
|
810 839 | #[::tokio::test]
|
811 840 | #[::tracing_test::traced_test]
|
812 841 | async fn rpc_v2_cbor_invalid_greeting_error_response() {
|
813 842 | let output = crate::error::InvalidGreeting {
|
814 843 | message: ::std::option::Option::Some("Hi".to_owned()),
|
815 844 | };
|
816 845 | let output = crate::error::GreetingWithErrorsError::InvalidGreeting(output);
|
817 846 | use ::aws_smithy_http_server::response::IntoResponse;
|
818 847 | let http_response = output.into_response();
|
819 848 | ::pretty_assertions::assert_eq!(
|
820 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
849 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
821 850 | http_response.status()
|
822 851 | );
|
823 852 | let expected_headers = [
|
824 853 | ("Content-Type", "application/cbor"),
|
825 854 | ("smithy-protocol", "rpc-v2-cbor"),
|
826 855 | ];
|
827 856 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
828 857 | http_response.headers(),
|
829 858 | expected_headers,
|
830 859 | ));
|
831 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
860 + | use ::http_body_util::BodyExt;
|
861 + | let body = http_response
|
862 + | .into_body()
|
863 + | .collect()
|
832 864 | .await
|
833 - | .expect("unable to extract body to bytes");
|
865 + | .expect("unable to collect body")
|
866 + | .to_bytes();
|
834 867 | ::aws_smithy_protocol_test::assert_ok(
|
835 868 | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4LnNtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNJbnZhbGlkR3JlZXRpbmdnTWVzc2FnZWJIaf8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
836 869 | );
|
837 870 | }
|
838 871 |
|
839 872 | /// Parses a complex error with no message member
|
840 873 | /// Test ID: RpcV2CborComplexError
|
841 874 | #[::tokio::test]
|
842 875 | #[::tracing_test::traced_test]
|
843 876 | async fn rpc_v2_cbor_complex_error_response() {
|
844 877 | let output = crate::error::ComplexError {
|
845 878 | top_level: ::std::option::Option::Some("Top level".to_owned()),
|
846 879 | nested: ::std::option::Option::Some(crate::model::ComplexNestedErrorData {
|
847 880 | foo: ::std::option::Option::Some("bar".to_owned()),
|
848 881 | }),
|
849 882 | };
|
850 883 | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
851 884 | use ::aws_smithy_http_server::response::IntoResponse;
|
852 885 | let http_response = output.into_response();
|
853 886 | ::pretty_assertions::assert_eq!(
|
854 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
887 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
855 888 | http_response.status()
|
856 889 | );
|
857 890 | let expected_headers = [
|
858 891 | ("Content-Type", "application/cbor"),
|
859 892 | ("smithy-protocol", "rpc-v2-cbor"),
|
860 893 | ];
|
861 894 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
862 895 | http_response.headers(),
|
863 896 | expected_headers,
|
864 897 | ));
|
865 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
898 + | use ::http_body_util::BodyExt;
|
899 + | let body = http_response
|
900 + | .into_body()
|
901 + | .collect()
|
866 902 | .await
|
867 - | .expect("unable to extract body to bytes");
|
903 + | .expect("unable to collect body")
|
904 + | .to_bytes();
|
868 905 | ::aws_smithy_protocol_test::assert_ok(
|
869 906 | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3JoVG9wTGV2ZWxpVG9wIGxldmVsZk5lc3RlZL9jRm9vY2Jhcv//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
870 907 | );
|
871 908 | }
|
872 909 | /// Test ID: RpcV2CborEmptyComplexError
|
873 910 | #[::tokio::test]
|
874 911 | #[::tracing_test::traced_test]
|
875 912 | async fn rpc_v2_cbor_empty_complex_error_response() {
|
876 913 | let output = crate::error::ComplexError {
|
877 914 | top_level: ::std::option::Option::None,
|
878 915 | nested: ::std::option::Option::None,
|
879 916 | };
|
880 917 | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
881 918 | use ::aws_smithy_http_server::response::IntoResponse;
|
882 919 | let http_response = output.into_response();
|
883 920 | ::pretty_assertions::assert_eq!(
|
884 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
921 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
885 922 | http_response.status()
|
886 923 | );
|
887 924 | let expected_headers = [
|
888 925 | ("Content-Type", "application/cbor"),
|
889 926 | ("smithy-protocol", "rpc-v2-cbor"),
|
890 927 | ];
|
891 928 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
892 929 | http_response.headers(),
|
893 930 | expected_headers,
|
894 931 | ));
|
895 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
932 + | use ::http_body_util::BodyExt;
|
933 + | let body = http_response
|
934 + | .into_body()
|
935 + | .collect()
|
896 936 | .await
|
897 - | .expect("unable to extract body to bytes");
|
937 + | .expect("unable to collect body")
|
938 + | .to_bytes();
|
898 939 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
899 940 | &body,
|
900 941 | "v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3L/",
|
901 942 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
902 943 | ));
|
903 944 | }
|
904 945 | }
|
905 946 |
|
906 947 | ::pin_project_lite::pin_project! {
|
907 948 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
908 949 | /// [`RecursiveShapesInput`](crate::input::RecursiveShapesInput) using modelled bindings.
|
909 950 | pub struct RecursiveShapesInputFuture {
|
910 951 | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RecursiveShapesInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
911 952 | }
|
912 953 | }
|
913 954 |
|
914 955 | impl std::future::Future for RecursiveShapesInputFuture {
|
915 956 | type Output = Result<
|
916 957 | crate::input::RecursiveShapesInput,
|
917 958 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
918 959 | >;
|
919 960 |
|
920 961 | fn poll(
|
921 962 | self: std::pin::Pin<&mut Self>,
|
922 963 | cx: &mut std::task::Context<'_>,
|
923 964 | ) -> std::task::Poll<Self::Output> {
|
924 965 | let this = self.project();
|
925 966 | this.inner.as_mut().poll(cx)
|
926 967 | }
|
927 968 | }
|
928 969 |
|
929 970 | impl<B>
|
930 971 | ::aws_smithy_http_server::request::FromRequest<
|
931 972 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
932 973 | B,
|
933 974 | > for crate::input::RecursiveShapesInput
|
934 975 | where
|
935 976 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
936 977 | B: 'static,
|
937 978 |
|
938 979 | B::Data: Send,
|
939 980 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
940 981 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
941 982 | {
|
942 983 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
943 984 | type Future = RecursiveShapesInputFuture;
|
944 985 |
|
945 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
986 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
946 987 | let fut = async move {
|
947 988 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
948 989 | request.headers(),
|
949 990 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
950 991 | ) {
|
951 992 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
952 993 | }
|
953 994 | crate::protocol_serde::shape_recursive_shapes::de_recursive_shapes_http_request(request)
|
954 995 | .await
|
955 996 | };
|
956 997 | use ::futures_util::future::TryFutureExt;
|
957 998 | let fut = fut.map_err(
|
958 999 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
959 1000 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
960 1001 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
961 1002 | e,
|
962 1003 | )
|
963 1004 | },
|
964 1005 | );
|
965 1006 | RecursiveShapesInputFuture {
|
966 1007 | inner: Box::pin(fut),
|
967 1008 | }
|
968 1009 | }
|
969 1010 | }
|
970 1011 | impl
|
971 1012 | ::aws_smithy_http_server::response::IntoResponse<
|
972 1013 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
973 1014 | > for crate::output::RecursiveShapesOutput
|
974 1015 | {
|
975 1016 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
976 1017 | match crate::protocol_serde::shape_recursive_shapes::ser_recursive_shapes_http_response(
|
977 1018 | self,
|
978 1019 | ) {
|
979 1020 | Ok(response) => response,
|
980 1021 | Err(e) => {
|
981 1022 | ::tracing::error!(error = %e, "failed to serialize response");
|
982 1023 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
983 1024 | }
|
984 1025 | }
|
985 1026 | }
|
986 1027 | }
|
987 1028 |
|
988 1029 | #[allow(unreachable_code, unused_variables)]
|
989 1030 | #[cfg(test)]
|
990 1031 | mod recursive_shapes_test {
|
991 1032 |
|
992 1033 | /// Serializes recursive structures
|
993 1034 | /// Test ID: RpcV2CborRecursiveShapes
|
994 1035 | #[::tokio::test]
|
995 1036 | #[::tracing_test::traced_test]
|
996 1037 | async fn rpc_v2_cbor_recursive_shapes_request() {
|
997 1038 | #[allow(unused_mut)]
|
998 - | let mut http_request = http::Request::builder()
|
1039 + | let mut http_request = ::http_1x::Request::builder()
|
999 1040 | .uri("/service/RpcV2Protocol/operation/RecursiveShapes")
|
1000 1041 | .method("POST")
|
1001 1042 | .header("Accept", "application/cbor")
|
1002 1043 | .header("Content-Type", "application/cbor")
|
1003 1044 | .header("smithy-protocol", "rpc-v2-cbor")
|
1004 - | .body(::aws_smithy_http_server::body::Body::from(
|
1045 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1005 1046 | ::bytes::Bytes::copy_from_slice(
|
1006 1047 | &::aws_smithy_protocol_test::decode_body_data("v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1007 1048 | )
|
1008 - | )).unwrap();
|
1049 + | ))).unwrap();
|
1009 1050 | #[allow(unused_mut)]
|
1010 1051 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1011 1052 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1012 - | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1053 + | let service = crate::service::RpcV2Protocol::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1013 1054 | .recursive_shapes(move |input: crate::input::RecursiveShapesInput| {
|
1014 1055 | let sender = sender.clone();
|
1015 1056 | async move {
|
1016 1057 | let result = { let expected =
|
1017 1058 | crate::input::RecursiveShapesInput {
|
1018 1059 | nested:
|
1019 1060 | ::std::option::Option::Some(
|
1020 1061 | crate::model::RecursiveShapesInputOutputNested1 {
|
1021 1062 | foo:
|
1022 1063 | ::std::option::Option::Some(
|
1241 1286 | #[allow(unreachable_code, unused_variables)]
|
1242 1287 | #[cfg(test)]
|
1243 1288 | mod rpc_v2_cbor_sparse_maps_test {
|
1244 1289 |
|
1245 1290 | /// Serializes sparse maps
|
1246 1291 | /// Test ID: RpcV2CborSparseMaps
|
1247 1292 | #[::tokio::test]
|
1248 1293 | #[::tracing_test::traced_test]
|
1249 1294 | async fn rpc_v2_cbor_sparse_maps_request() {
|
1250 1295 | #[allow(unused_mut)]
|
1251 - | let mut http_request = http::Request::builder()
|
1296 + | let mut http_request = ::http_1x::Request::builder()
|
1252 1297 | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1253 1298 | .method("POST")
|
1254 1299 | .header("Accept", "application/cbor")
|
1255 1300 | .header("Content-Type", "application/cbor")
|
1256 1301 | .header("smithy-protocol", "rpc-v2-cbor")
|
1257 - | .body(::aws_smithy_http_server::body::Body::from(
|
1258 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1259 - | "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////".as_bytes(),
|
1302 + | .body(::aws_smithy_http_server::body::boxed(
|
1303 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1304 + | &::aws_smithy_protocol_test::decode_body_data(
|
1305 + | "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////"
|
1306 + | .as_bytes(),
|
1260 1307 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1308 + | ),
|
1261 1309 | )),
|
1262 1310 | ))
|
1263 1311 | .unwrap();
|
1264 1312 | #[allow(unused_mut)]
|
1265 1313 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1266 1314 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1267 - | let service =
|
1268 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1315 + | let service = crate::service::RpcV2Protocol::builder::<
|
1316 + | ::aws_smithy_http_server::body::BoxBody,
|
1317 + | _,
|
1318 + | _,
|
1319 + | _,
|
1320 + | >(config)
|
1269 1321 | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1270 1322 | let sender = sender.clone();
|
1271 1323 | async move {
|
1272 1324 | let result = {
|
1273 1325 | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1274 1326 | sparse_struct_map: ::std::option::Option::Some({
|
1275 1327 | let mut ret = ::std::collections::HashMap::new();
|
1276 1328 | ret.insert(
|
1277 1329 | "foo".to_owned(),
|
1278 1330 | ::std::option::Option::Some(crate::model::GreetingStruct {
|
1279 1331 | hi: ::std::option::Option::Some("there".to_owned()),
|
1280 1332 | }),
|
1281 1333 | );
|
1282 1334 | ret.insert(
|
1283 1335 | "baz".to_owned(),
|
1284 1336 | ::std::option::Option::Some(crate::model::GreetingStruct {
|
1285 1337 | hi: ::std::option::Option::Some("bye".to_owned()),
|
1286 1338 | }),
|
1287 1339 | );
|
1288 1340 | ret
|
1289 1341 | }),
|
1290 1342 | sparse_number_map: ::std::option::Option::None,
|
1291 1343 | sparse_boolean_map: ::std::option::Option::None,
|
1292 1344 | sparse_string_map: ::std::option::Option::None,
|
1293 1345 | sparse_set_map: ::std::option::Option::None,
|
1294 1346 | };
|
1295 1347 | ::pretty_assertions::assert_eq!(input, expected);
|
1296 1348 | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1297 1349 | sparse_struct_map: ::std::option::Option::None,
|
1298 1350 | sparse_number_map: ::std::option::Option::None,
|
1299 1351 | sparse_boolean_map: ::std::option::Option::None,
|
1300 1352 | sparse_string_map: ::std::option::Option::None,
|
1301 1353 | sparse_set_map: ::std::option::Option::None,
|
1302 1354 | };
|
1303 1355 | Ok(output)
|
1304 1356 | };
|
1305 1357 | sender.send(()).await.expect("receiver dropped early");
|
1306 1358 | result
|
1307 1359 | }
|
1308 1360 | })
|
1309 1361 | .build_unchecked();
|
1310 1362 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1311 1363 | .await
|
1312 1364 | .expect("unable to make an HTTP request");
|
1313 1365 | assert!(
|
1314 1366 | receiver.recv().await.is_some(),
|
1315 1367 | "we expected operation handler to be invoked but it was not entered"
|
1316 1368 | );
|
1317 1369 | }
|
1318 1370 |
|
1319 1371 | /// Serializes null map values in sparse maps
|
1320 1372 | /// Test ID: RpcV2CborSerializesNullMapValues
|
1321 1373 | #[::tokio::test]
|
1322 1374 | #[::tracing_test::traced_test]
|
1323 1375 | async fn rpc_v2_cbor_serializes_null_map_values_request() {
|
1324 1376 | #[allow(unused_mut)]
|
1325 - | let mut http_request = http::Request::builder()
|
1377 + | let mut http_request = ::http_1x::Request::builder()
|
1326 1378 | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1327 1379 | .method("POST")
|
1328 1380 | .header("Accept", "application/cbor")
|
1329 1381 | .header("Content-Type", "application/cbor")
|
1330 1382 | .header("smithy-protocol", "rpc-v2-cbor")
|
1331 - | .body(::aws_smithy_http_server::body::Body::from(
|
1383 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1332 1384 | ::bytes::Bytes::copy_from_slice(
|
1333 1385 | &::aws_smithy_protocol_test::decode_body_data("v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1334 1386 | )
|
1335 - | )).unwrap();
|
1387 + | ))).unwrap();
|
1336 1388 | #[allow(unused_mut)]
|
1337 1389 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1338 1390 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1339 - | let service =
|
1340 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1391 + | let service = crate::service::RpcV2Protocol::builder::<
|
1392 + | ::aws_smithy_http_server::body::BoxBody,
|
1393 + | _,
|
1394 + | _,
|
1395 + | _,
|
1396 + | >(config)
|
1341 1397 | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1342 1398 | let sender = sender.clone();
|
1343 1399 | async move {
|
1344 1400 | let result = {
|
1345 1401 | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1346 1402 | sparse_boolean_map: ::std::option::Option::Some({
|
1347 1403 | let mut ret = ::std::collections::HashMap::new();
|
1348 1404 | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1349 1405 | ret
|
1350 1406 | }),
|
1351 1407 | sparse_number_map: ::std::option::Option::Some({
|
1352 1408 | let mut ret = ::std::collections::HashMap::new();
|
1353 1409 | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1354 1410 | ret
|
1355 1411 | }),
|
1356 1412 | sparse_string_map: ::std::option::Option::Some({
|
1357 1413 | let mut ret = ::std::collections::HashMap::new();
|
1358 1414 | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1359 1415 | ret
|
1360 1416 | }),
|
1361 1417 | sparse_struct_map: ::std::option::Option::Some({
|
1362 1418 | let mut ret = ::std::collections::HashMap::new();
|
1363 1419 | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1364 1420 | ret
|
1365 1421 | }),
|
1366 1422 | sparse_set_map: ::std::option::Option::None,
|
1367 1423 | };
|
1368 1424 | ::pretty_assertions::assert_eq!(input, expected);
|
1369 1425 | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1370 1426 | sparse_struct_map: ::std::option::Option::None,
|
1371 1427 | sparse_number_map: ::std::option::Option::None,
|
1372 1428 | sparse_boolean_map: ::std::option::Option::None,
|
1373 1429 | sparse_string_map: ::std::option::Option::None,
|
1374 1430 | sparse_set_map: ::std::option::Option::None,
|
1375 1431 | };
|
1376 1432 | Ok(output)
|
1377 1433 | };
|
1378 1434 | sender.send(()).await.expect("receiver dropped early");
|
1379 1435 | result
|
1380 1436 | }
|
1381 1437 | })
|
1382 1438 | .build_unchecked();
|
1383 1439 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1384 1440 | .await
|
1385 1441 | .expect("unable to make an HTTP request");
|
1386 1442 | assert!(
|
1387 1443 | receiver.recv().await.is_some(),
|
1388 1444 | "we expected operation handler to be invoked but it was not entered"
|
1389 1445 | );
|
1390 1446 | }
|
1391 1447 |
|
1392 1448 | /// A request that contains a sparse map of sets
|
1393 1449 | /// Test ID: RpcV2CborSerializesSparseSetMap
|
1394 1450 | #[::tokio::test]
|
1395 1451 | #[::tracing_test::traced_test]
|
1396 1452 | async fn rpc_v2_cbor_serializes_sparse_set_map_request() {
|
1397 1453 | #[allow(unused_mut)]
|
1398 - | let mut http_request = http::Request::builder()
|
1454 + | let mut http_request = ::http_1x::Request::builder()
|
1399 1455 | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1400 1456 | .method("POST")
|
1401 1457 | .header("Accept", "application/cbor")
|
1402 1458 | .header("Content-Type", "application/cbor")
|
1403 1459 | .header("smithy-protocol", "rpc-v2-cbor")
|
1404 - | .body(::aws_smithy_http_server::body::Body::from(
|
1405 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1460 + | .body(::aws_smithy_http_server::body::boxed(
|
1461 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1462 + | &::aws_smithy_protocol_test::decode_body_data(
|
1406 1463 | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL///8=".as_bytes(),
|
1407 1464 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1465 + | ),
|
1408 1466 | )),
|
1409 1467 | ))
|
1410 1468 | .unwrap();
|
1411 1469 | #[allow(unused_mut)]
|
1412 1470 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1413 1471 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1414 - | let service =
|
1415 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1472 + | let service = crate::service::RpcV2Protocol::builder::<
|
1473 + | ::aws_smithy_http_server::body::BoxBody,
|
1474 + | _,
|
1475 + | _,
|
1476 + | _,
|
1477 + | >(config)
|
1416 1478 | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1417 1479 | let sender = sender.clone();
|
1418 1480 | async move {
|
1419 1481 | let result = {
|
1420 1482 | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1421 1483 | sparse_set_map: ::std::option::Option::Some({
|
1422 1484 | let mut ret = ::std::collections::HashMap::new();
|
1423 1485 | ret.insert(
|
1424 1486 | "x".to_owned(),
|
1425 1487 | ::std::option::Option::Some(
|
1426 1488 | vec![].try_into().expect("this is only used in tests"),
|
1427 1489 | ),
|
1428 1490 | );
|
1429 1491 | ret.insert(
|
1430 1492 | "y".to_owned(),
|
1431 1493 | ::std::option::Option::Some(
|
1432 1494 | vec!["a".to_owned(), "b".to_owned()]
|
1433 1495 | .try_into()
|
1434 1496 | .expect("this is only used in tests"),
|
1435 1497 | ),
|
1436 1498 | );
|
1437 1499 | ret
|
1438 1500 | }),
|
1439 1501 | sparse_struct_map: ::std::option::Option::None,
|
1440 1502 | sparse_number_map: ::std::option::Option::None,
|
1441 1503 | sparse_boolean_map: ::std::option::Option::None,
|
1442 1504 | sparse_string_map: ::std::option::Option::None,
|
1443 1505 | };
|
1444 1506 | ::pretty_assertions::assert_eq!(input, expected);
|
1445 1507 | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1446 1508 | sparse_struct_map: ::std::option::Option::None,
|
1447 1509 | sparse_number_map: ::std::option::Option::None,
|
1448 1510 | sparse_boolean_map: ::std::option::Option::None,
|
1449 1511 | sparse_string_map: ::std::option::Option::None,
|
1450 1512 | sparse_set_map: ::std::option::Option::None,
|
1451 1513 | };
|
1452 1514 | Ok(output)
|
1453 1515 | };
|
1454 1516 | sender.send(()).await.expect("receiver dropped early");
|
1455 1517 | result
|
1456 1518 | }
|
1457 1519 | })
|
1458 1520 | .build_unchecked();
|
1459 1521 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1460 1522 | .await
|
1461 1523 | .expect("unable to make an HTTP request");
|
1462 1524 | assert!(
|
1463 1525 | receiver.recv().await.is_some(),
|
1464 1526 | "we expected operation handler to be invoked but it was not entered"
|
1465 1527 | );
|
1466 1528 | }
|
1467 1529 |
|
1468 1530 | /// A request that contains a sparse map of sets.
|
1469 1531 | /// Test ID: RpcV2CborSerializesSparseSetMapAndRetainsNull
|
1470 1532 | #[::tokio::test]
|
1471 1533 | #[::tracing_test::traced_test]
|
1472 1534 | async fn rpc_v2_cbor_serializes_sparse_set_map_and_retains_null_request() {
|
1473 1535 | #[allow(unused_mut)]
|
1474 - | let mut http_request = http::Request::builder()
|
1536 + | let mut http_request = ::http_1x::Request::builder()
|
1475 1537 | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1476 1538 | .method("POST")
|
1477 1539 | .header("Accept", "application/cbor")
|
1478 1540 | .header("Content-Type", "application/cbor")
|
1479 1541 | .header("smithy-protocol", "rpc-v2-cbor")
|
1480 - | .body(::aws_smithy_http_server::body::Body::from(
|
1481 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1542 + | .body(::aws_smithy_http_server::body::boxed(
|
1543 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1544 + | &::aws_smithy_protocol_test::decode_body_data(
|
1482 1545 | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=".as_bytes(),
|
1483 1546 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1547 + | ),
|
1484 1548 | )),
|
1485 1549 | ))
|
1486 1550 | .unwrap();
|
1487 1551 | #[allow(unused_mut)]
|
1488 1552 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1489 1553 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1490 - | let service =
|
1491 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1554 + | let service = crate::service::RpcV2Protocol::builder::<
|
1555 + | ::aws_smithy_http_server::body::BoxBody,
|
1556 + | _,
|
1557 + | _,
|
1558 + | _,
|
1559 + | >(config)
|
1492 1560 | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1493 1561 | let sender = sender.clone();
|
1494 1562 | async move {
|
1495 1563 | let result = {
|
1496 1564 | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1497 1565 | sparse_set_map: ::std::option::Option::Some({
|
1498 1566 | let mut ret = ::std::collections::HashMap::new();
|
1499 1567 | ret.insert(
|
1500 1568 | "x".to_owned(),
|
1501 1569 | ::std::option::Option::Some(
|
1502 1570 | vec![].try_into().expect("this is only used in tests"),
|
1503 1571 | ),
|
1504 1572 | );
|
1505 1573 | ret.insert(
|
1506 1574 | "y".to_owned(),
|
1507 1575 | ::std::option::Option::Some(
|
1508 1576 | vec!["a".to_owned(), "b".to_owned()]
|
1509 1577 | .try_into()
|
1510 1578 | .expect("this is only used in tests"),
|
1511 1579 | ),
|
1512 1580 | );
|
1513 1581 | ret.insert("z".to_owned(), ::std::option::Option::None);
|
1514 1582 | ret
|
1515 1583 | }),
|
1516 1584 | sparse_struct_map: ::std::option::Option::None,
|
1517 1585 | sparse_number_map: ::std::option::Option::None,
|
1518 1586 | sparse_boolean_map: ::std::option::Option::None,
|
1519 1587 | sparse_string_map: ::std::option::Option::None,
|
1520 1588 | };
|
1521 1589 | ::pretty_assertions::assert_eq!(input, expected);
|
1522 1590 | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1523 1591 | sparse_struct_map: ::std::option::Option::None,
|
1524 1592 | sparse_number_map: ::std::option::Option::None,
|
1525 1593 | sparse_boolean_map: ::std::option::Option::None,
|
1526 1594 | sparse_string_map: ::std::option::Option::None,
|
1527 1595 | sparse_set_map: ::std::option::Option::None,
|
1528 1596 | };
|
1529 1597 | Ok(output)
|
1530 1598 | };
|
1531 1599 | sender.send(()).await.expect("receiver dropped early");
|
1532 1600 | result
|
1533 1601 | }
|
1534 1602 | })
|
1535 1603 | .build_unchecked();
|
1536 1604 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1537 1605 | .await
|
1538 1606 | .expect("unable to make an HTTP request");
|
1539 1607 | assert!(
|
1540 1608 | receiver.recv().await.is_some(),
|
1541 1609 | "we expected operation handler to be invoked but it was not entered"
|
1542 1610 | );
|
1543 1611 | }
|
1544 1612 |
|
1545 1613 | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
1546 1614 | /// Test ID: RpcV2CborSerializesZeroValuesInSparseMaps
|
1547 1615 | #[::tokio::test]
|
1548 1616 | #[::tracing_test::traced_test]
|
1549 1617 | async fn rpc_v2_cbor_serializes_zero_values_in_sparse_maps_request() {
|
1550 1618 | #[allow(unused_mut)]
|
1551 - | let mut http_request = http::Request::builder()
|
1619 + | let mut http_request = ::http_1x::Request::builder()
|
1552 1620 | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1553 1621 | .method("POST")
|
1554 1622 | .header("Accept", "application/cbor")
|
1555 1623 | .header("Content-Type", "application/cbor")
|
1556 1624 | .header("smithy-protocol", "rpc-v2-cbor")
|
1557 - | .body(::aws_smithy_http_server::body::Body::from(
|
1558 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1625 + | .body(::aws_smithy_http_server::body::boxed(
|
1626 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1627 + | &::aws_smithy_protocol_test::decode_body_data(
|
1559 1628 | "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//".as_bytes(),
|
1560 1629 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1630 + | ),
|
1561 1631 | )),
|
1562 1632 | ))
|
1563 1633 | .unwrap();
|
1564 1634 | #[allow(unused_mut)]
|
1565 1635 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1566 1636 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1567 - | let service =
|
1568 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1637 + | let service = crate::service::RpcV2Protocol::builder::<
|
1638 + | ::aws_smithy_http_server::body::BoxBody,
|
1639 + | _,
|
1640 + | _,
|
1641 + | _,
|
1642 + | >(config)
|
1569 1643 | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1570 1644 | let sender = sender.clone();
|
1571 1645 | async move {
|
1572 1646 | let result = {
|
1573 1647 | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1574 1648 | sparse_number_map: ::std::option::Option::Some({
|
1575 1649 | let mut ret = ::std::collections::HashMap::new();
|
1576 1650 | ret.insert("x".to_owned(), ::std::option::Option::Some(0));
|
1577 1651 | ret
|
1578 1652 | }),
|
1632 1706 | ret
|
1633 1707 | }),
|
1634 1708 | sparse_number_map: ::std::option::Option::None,
|
1635 1709 | sparse_boolean_map: ::std::option::Option::None,
|
1636 1710 | sparse_string_map: ::std::option::Option::None,
|
1637 1711 | sparse_set_map: ::std::option::Option::None,
|
1638 1712 | };
|
1639 1713 | use ::aws_smithy_http_server::response::IntoResponse;
|
1640 1714 | let http_response = output.into_response();
|
1641 1715 | ::pretty_assertions::assert_eq!(
|
1642 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1716 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1643 1717 | http_response.status()
|
1644 1718 | );
|
1645 1719 | let expected_headers = [
|
1646 1720 | ("Content-Type", "application/cbor"),
|
1647 1721 | ("smithy-protocol", "rpc-v2-cbor"),
|
1648 1722 | ];
|
1649 1723 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1650 1724 | http_response.headers(),
|
1651 1725 | expected_headers,
|
1652 1726 | ));
|
1653 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1727 + | use ::http_body_util::BodyExt;
|
1728 + | let body = http_response
|
1729 + | .into_body()
|
1730 + | .collect()
|
1654 1731 | .await
|
1655 - | .expect("unable to extract body to bytes");
|
1732 + | .expect("unable to collect body")
|
1733 + | .to_bytes();
|
1656 1734 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1657 1735 | &body,
|
1658 1736 | "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////",
|
1659 1737 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1660 1738 | ));
|
1661 1739 | }
|
1662 1740 |
|
1663 1741 | /// Deserializes null map values
|
1664 1742 | /// Test ID: RpcV2CborDeserializesNullMapValues
|
1665 1743 | #[::tokio::test]
|
1666 1744 | #[::tracing_test::traced_test]
|
1667 1745 | async fn rpc_v2_cbor_deserializes_null_map_values_response() {
|
1668 1746 | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1669 1747 | sparse_boolean_map: ::std::option::Option::Some({
|
1670 1748 | let mut ret = ::std::collections::HashMap::new();
|
1671 1749 | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1672 1750 | ret
|
1673 1751 | }),
|
1674 1752 | sparse_number_map: ::std::option::Option::Some({
|
1675 1753 | let mut ret = ::std::collections::HashMap::new();
|
1676 1754 | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1677 1755 | ret
|
1678 1756 | }),
|
1679 1757 | sparse_string_map: ::std::option::Option::Some({
|
1680 1758 | let mut ret = ::std::collections::HashMap::new();
|
1681 1759 | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1682 1760 | ret
|
1683 1761 | }),
|
1684 1762 | sparse_struct_map: ::std::option::Option::Some({
|
1685 1763 | let mut ret = ::std::collections::HashMap::new();
|
1686 1764 | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1687 1765 | ret
|
1688 1766 | }),
|
1689 1767 | sparse_set_map: ::std::option::Option::None,
|
1690 1768 | };
|
1691 1769 | use ::aws_smithy_http_server::response::IntoResponse;
|
1692 1770 | let http_response = output.into_response();
|
1693 1771 | ::pretty_assertions::assert_eq!(
|
1694 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1772 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1695 1773 | http_response.status()
|
1696 1774 | );
|
1697 1775 | let expected_headers = [
|
1698 1776 | ("Content-Type", "application/cbor"),
|
1699 1777 | ("smithy-protocol", "rpc-v2-cbor"),
|
1700 1778 | ];
|
1701 1779 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1702 1780 | http_response.headers(),
|
1703 1781 | expected_headers,
|
1704 1782 | ));
|
1705 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1783 + | use ::http_body_util::BodyExt;
|
1784 + | let body = http_response
|
1785 + | .into_body()
|
1786 + | .collect()
|
1706 1787 | .await
|
1707 - | .expect("unable to extract body to bytes");
|
1788 + | .expect("unable to collect body")
|
1789 + | .to_bytes();
|
1708 1790 | ::aws_smithy_protocol_test::assert_ok(
|
1709 1791 | ::aws_smithy_protocol_test::validate_body(&body, "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1710 1792 | );
|
1711 1793 | }
|
1712 1794 |
|
1713 1795 | /// A response that contains a sparse map of sets
|
1714 1796 | /// Test ID: RpcV2CborDeserializesSparseSetMap
|
1715 1797 | #[::tokio::test]
|
1716 1798 | #[::tracing_test::traced_test]
|
1717 1799 | async fn rpc_v2_cbor_deserializes_sparse_set_map_response() {
|
1718 1800 | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1719 1801 | sparse_set_map: ::std::option::Option::Some({
|
1720 1802 | let mut ret = ::std::collections::HashMap::new();
|
1721 1803 | ret.insert(
|
1722 1804 | "x".to_owned(),
|
1723 1805 | ::std::option::Option::Some(
|
1724 1806 | vec![].try_into().expect("this is only used in tests"),
|
1725 1807 | ),
|
1726 1808 | );
|
1727 1809 | ret.insert(
|
1728 1810 | "y".to_owned(),
|
1729 1811 | ::std::option::Option::Some(
|
1730 1812 | vec!["a".to_owned(), "b".to_owned()]
|
1731 1813 | .try_into()
|
1732 1814 | .expect("this is only used in tests"),
|
1733 1815 | ),
|
1734 1816 | );
|
1735 1817 | ret
|
1736 1818 | }),
|
1737 1819 | sparse_struct_map: ::std::option::Option::None,
|
1738 1820 | sparse_number_map: ::std::option::Option::None,
|
1739 1821 | sparse_boolean_map: ::std::option::Option::None,
|
1740 1822 | sparse_string_map: ::std::option::Option::None,
|
1741 1823 | };
|
1742 1824 | use ::aws_smithy_http_server::response::IntoResponse;
|
1743 1825 | let http_response = output.into_response();
|
1744 1826 | ::pretty_assertions::assert_eq!(
|
1745 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1827 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1746 1828 | http_response.status()
|
1747 1829 | );
|
1748 1830 | let expected_headers = [
|
1749 1831 | ("Content-Type", "application/cbor"),
|
1750 1832 | ("smithy-protocol", "rpc-v2-cbor"),
|
1751 1833 | ];
|
1752 1834 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1753 1835 | http_response.headers(),
|
1754 1836 | expected_headers,
|
1755 1837 | ));
|
1756 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1838 + | use ::http_body_util::BodyExt;
|
1839 + | let body = http_response
|
1840 + | .into_body()
|
1841 + | .collect()
|
1757 1842 | .await
|
1758 - | .expect("unable to extract body to bytes");
|
1843 + | .expect("unable to collect body")
|
1844 + | .to_bytes();
|
1759 1845 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1760 1846 | &body,
|
1761 1847 | "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=",
|
1762 1848 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1763 1849 | ));
|
1764 1850 | }
|
1765 1851 |
|
1766 1852 | /// A response that contains a sparse map of sets with a null
|
1767 1853 | /// Test ID: RpcV2CborDeserializesSparseSetMapAndRetainsNull
|
1768 1854 | #[::tokio::test]
|
1769 1855 | #[::tracing_test::traced_test]
|
1770 1856 | async fn rpc_v2_cbor_deserializes_sparse_set_map_and_retains_null_response() {
|
1771 1857 | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1772 1858 | sparse_set_map: ::std::option::Option::Some({
|
1773 1859 | let mut ret = ::std::collections::HashMap::new();
|
1774 1860 | ret.insert(
|
1775 1861 | "x".to_owned(),
|
1776 1862 | ::std::option::Option::Some(
|
1777 1863 | vec![].try_into().expect("this is only used in tests"),
|
1778 1864 | ),
|
1779 1865 | );
|
1780 1866 | ret.insert(
|
1781 1867 | "y".to_owned(),
|
1782 1868 | ::std::option::Option::Some(
|
1783 1869 | vec!["a".to_owned(), "b".to_owned()]
|
1784 1870 | .try_into()
|
1785 1871 | .expect("this is only used in tests"),
|
1786 1872 | ),
|
1787 1873 | );
|
1788 1874 | ret.insert("z".to_owned(), ::std::option::Option::None);
|
1789 1875 | ret
|
1790 1876 | }),
|
1791 1877 | sparse_struct_map: ::std::option::Option::None,
|
1792 1878 | sparse_number_map: ::std::option::Option::None,
|
1793 1879 | sparse_boolean_map: ::std::option::Option::None,
|
1794 1880 | sparse_string_map: ::std::option::Option::None,
|
1795 1881 | };
|
1796 1882 | use ::aws_smithy_http_server::response::IntoResponse;
|
1797 1883 | let http_response = output.into_response();
|
1798 1884 | ::pretty_assertions::assert_eq!(
|
1799 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1885 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1800 1886 | http_response.status()
|
1801 1887 | );
|
1802 1888 | let expected_headers = [
|
1803 1889 | ("Content-Type", "application/cbor"),
|
1804 1890 | ("smithy-protocol", "rpc-v2-cbor"),
|
1805 1891 | ];
|
1806 1892 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1807 1893 | http_response.headers(),
|
1808 1894 | expected_headers,
|
1809 1895 | ));
|
1810 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1896 + | use ::http_body_util::BodyExt;
|
1897 + | let body = http_response
|
1898 + | .into_body()
|
1899 + | .collect()
|
1811 1900 | .await
|
1812 - | .expect("unable to extract body to bytes");
|
1901 + | .expect("unable to collect body")
|
1902 + | .to_bytes();
|
1813 1903 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1814 1904 | &body,
|
1815 1905 | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=",
|
1816 1906 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1817 1907 | ));
|
1818 1908 | }
|
1819 1909 |
|
1820 1910 | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
1821 1911 | /// Test ID: RpcV2CborDeserializesZeroValuesInSparseMaps
|
1822 1912 | #[::tokio::test]
|
1823 1913 | #[::tracing_test::traced_test]
|
1824 1914 | async fn rpc_v2_cbor_deserializes_zero_values_in_sparse_maps_response() {
|
1825 1915 | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1826 1916 | sparse_number_map: ::std::option::Option::Some({
|
1827 1917 | let mut ret = ::std::collections::HashMap::new();
|
1828 1918 | ret.insert("x".to_owned(), ::std::option::Option::Some(0));
|
1829 1919 | ret
|
1830 1920 | }),
|
1831 1921 | sparse_boolean_map: ::std::option::Option::Some({
|
1832 1922 | let mut ret = ::std::collections::HashMap::new();
|
1833 1923 | ret.insert("x".to_owned(), ::std::option::Option::Some(false));
|
1834 1924 | ret
|
1835 1925 | }),
|
1836 1926 | sparse_struct_map: ::std::option::Option::None,
|
1837 1927 | sparse_string_map: ::std::option::Option::None,
|
1838 1928 | sparse_set_map: ::std::option::Option::None,
|
1839 1929 | };
|
1840 1930 | use ::aws_smithy_http_server::response::IntoResponse;
|
1841 1931 | let http_response = output.into_response();
|
1842 1932 | ::pretty_assertions::assert_eq!(
|
1843 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1933 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1844 1934 | http_response.status()
|
1845 1935 | );
|
1846 1936 | let expected_headers = [
|
1847 1937 | ("Content-Type", "application/cbor"),
|
1848 1938 | ("smithy-protocol", "rpc-v2-cbor"),
|
1849 1939 | ];
|
1850 1940 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1851 1941 | http_response.headers(),
|
1852 1942 | expected_headers,
|
1853 1943 | ));
|
1854 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1944 + | use ::http_body_util::BodyExt;
|
1945 + | let body = http_response
|
1946 + | .into_body()
|
1947 + | .collect()
|
1855 1948 | .await
|
1856 - | .expect("unable to extract body to bytes");
|
1949 + | .expect("unable to collect body")
|
1950 + | .to_bytes();
|
1857 1951 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1858 1952 | &body,
|
1859 1953 | "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//",
|
1860 1954 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1861 1955 | ));
|
1862 1956 | }
|
1863 1957 | }
|
1864 1958 |
|
1865 1959 | ::pin_project_lite::pin_project! {
|
1866 1960 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1867 1961 | /// [`RpcV2CborDenseMapsInput`](crate::input::RpcV2CborDenseMapsInput) using modelled bindings.
|
1868 1962 | pub struct RpcV2CborDenseMapsInputFuture {
|
1869 1963 | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborDenseMapsInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
1870 1964 | }
|
1871 1965 | }
|
1872 1966 |
|
1873 1967 | impl std::future::Future for RpcV2CborDenseMapsInputFuture {
|
1874 1968 | type Output = Result<
|
1875 1969 | crate::input::RpcV2CborDenseMapsInput,
|
1876 1970 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
1877 1971 | >;
|
1878 1972 |
|
1879 1973 | fn poll(
|
1880 1974 | self: std::pin::Pin<&mut Self>,
|
1881 1975 | cx: &mut std::task::Context<'_>,
|
1882 1976 | ) -> std::task::Poll<Self::Output> {
|
1883 1977 | let this = self.project();
|
1884 1978 | this.inner.as_mut().poll(cx)
|
1885 1979 | }
|
1886 1980 | }
|
1887 1981 |
|
1888 1982 | impl<B>
|
1889 1983 | ::aws_smithy_http_server::request::FromRequest<
|
1890 1984 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1891 1985 | B,
|
1892 1986 | > for crate::input::RpcV2CborDenseMapsInput
|
1893 1987 | where
|
1894 1988 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
1895 1989 | B: 'static,
|
1896 1990 |
|
1897 1991 | B::Data: Send,
|
1898 1992 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
1899 1993 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
1900 1994 | {
|
1901 1995 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
1902 1996 | type Future = RpcV2CborDenseMapsInputFuture;
|
1903 1997 |
|
1904 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1998 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
1905 1999 | let fut = async move {
|
1906 2000 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1907 2001 | request.headers(),
|
1908 2002 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
1909 2003 | ) {
|
1910 2004 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
1911 2005 | }
|
1912 2006 | crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::de_rpc_v2_cbor_dense_maps_http_request(request)
|
1913 2007 | .await
|
1914 2008 | };
|
1963 2057 | #[allow(unreachable_code, unused_variables)]
|
1964 2058 | #[cfg(test)]
|
1965 2059 | mod rpc_v2_cbor_dense_maps_test {
|
1966 2060 |
|
1967 2061 | /// Serializes maps
|
1968 2062 | /// Test ID: RpcV2CborMaps
|
1969 2063 | #[::tokio::test]
|
1970 2064 | #[::tracing_test::traced_test]
|
1971 2065 | async fn rpc_v2_cbor_maps_request() {
|
1972 2066 | #[allow(unused_mut)]
|
1973 - | let mut http_request = http::Request::builder()
|
2067 + | let mut http_request = ::http_1x::Request::builder()
|
1974 2068 | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
1975 2069 | .method("POST")
|
1976 2070 | .header("Accept", "application/cbor")
|
1977 2071 | .header("Content-Type", "application/cbor")
|
1978 2072 | .header("smithy-protocol", "rpc-v2-cbor")
|
1979 - | .body(::aws_smithy_http_server::body::Body::from(
|
1980 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2073 + | .body(::aws_smithy_http_server::body::boxed(
|
2074 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2075 + | &::aws_smithy_protocol_test::decode_body_data(
|
1981 2076 | "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==".as_bytes(),
|
1982 2077 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2078 + | ),
|
1983 2079 | )),
|
1984 2080 | ))
|
1985 2081 | .unwrap();
|
1986 2082 | #[allow(unused_mut)]
|
1987 2083 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1988 2084 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1989 - | let service =
|
1990 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2085 + | let service = crate::service::RpcV2Protocol::builder::<
|
2086 + | ::aws_smithy_http_server::body::BoxBody,
|
2087 + | _,
|
2088 + | _,
|
2089 + | _,
|
2090 + | >(config)
|
1991 2091 | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
1992 2092 | let sender = sender.clone();
|
1993 2093 | async move {
|
1994 2094 | let result = {
|
1995 2095 | let expected = crate::input::RpcV2CborDenseMapsInput {
|
1996 2096 | dense_struct_map: ::std::option::Option::Some({
|
1997 2097 | let mut ret = ::std::collections::HashMap::new();
|
1998 2098 | ret.insert(
|
1999 2099 | "foo".to_owned(),
|
2000 2100 | crate::model::GreetingStruct {
|
2001 2101 | hi: ::std::option::Option::Some("there".to_owned()),
|
2002 2102 | },
|
2003 2103 | );
|
2004 2104 | ret.insert(
|
2005 2105 | "baz".to_owned(),
|
2006 2106 | crate::model::GreetingStruct {
|
2007 2107 | hi: ::std::option::Option::Some("bye".to_owned()),
|
2008 2108 | },
|
2009 2109 | );
|
2010 2110 | ret
|
2011 2111 | }),
|
2012 2112 | dense_number_map: ::std::option::Option::None,
|
2013 2113 | dense_boolean_map: ::std::option::Option::None,
|
2014 2114 | dense_string_map: ::std::option::Option::None,
|
2015 2115 | dense_set_map: ::std::option::Option::None,
|
2016 2116 | };
|
2017 2117 | ::pretty_assertions::assert_eq!(input, expected);
|
2018 2118 | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2019 2119 | dense_struct_map: ::std::option::Option::None,
|
2020 2120 | dense_number_map: ::std::option::Option::None,
|
2021 2121 | dense_boolean_map: ::std::option::Option::None,
|
2022 2122 | dense_string_map: ::std::option::Option::None,
|
2023 2123 | dense_set_map: ::std::option::Option::None,
|
2024 2124 | };
|
2025 2125 | Ok(output)
|
2026 2126 | };
|
2027 2127 | sender.send(()).await.expect("receiver dropped early");
|
2028 2128 | result
|
2029 2129 | }
|
2030 2130 | })
|
2031 2131 | .build_unchecked();
|
2032 2132 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2033 2133 | .await
|
2034 2134 | .expect("unable to make an HTTP request");
|
2035 2135 | assert!(
|
2036 2136 | receiver.recv().await.is_some(),
|
2037 2137 | "we expected operation handler to be invoked but it was not entered"
|
2038 2138 | );
|
2039 2139 | }
|
2040 2140 |
|
2041 2141 | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
2042 2142 | /// Test ID: RpcV2CborSerializesZeroValuesInMaps
|
2043 2143 | #[::tokio::test]
|
2044 2144 | #[::tracing_test::traced_test]
|
2045 2145 | async fn rpc_v2_cbor_serializes_zero_values_in_maps_request() {
|
2046 2146 | #[allow(unused_mut)]
|
2047 - | let mut http_request = http::Request::builder()
|
2147 + | let mut http_request = ::http_1x::Request::builder()
|
2048 2148 | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
2049 2149 | .method("POST")
|
2050 2150 | .header("Accept", "application/cbor")
|
2051 2151 | .header("Content-Type", "application/cbor")
|
2052 2152 | .header("smithy-protocol", "rpc-v2-cbor")
|
2053 - | .body(::aws_smithy_http_server::body::Body::from(
|
2054 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2153 + | .body(::aws_smithy_http_server::body::boxed(
|
2154 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2155 + | &::aws_smithy_protocol_test::decode_body_data(
|
2055 2156 | "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==".as_bytes(),
|
2056 2157 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2158 + | ),
|
2057 2159 | )),
|
2058 2160 | ))
|
2059 2161 | .unwrap();
|
2060 2162 | #[allow(unused_mut)]
|
2061 2163 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2062 2164 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2063 - | let service =
|
2064 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2165 + | let service = crate::service::RpcV2Protocol::builder::<
|
2166 + | ::aws_smithy_http_server::body::BoxBody,
|
2167 + | _,
|
2168 + | _,
|
2169 + | _,
|
2170 + | >(config)
|
2065 2171 | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
2066 2172 | let sender = sender.clone();
|
2067 2173 | async move {
|
2068 2174 | let result = {
|
2069 2175 | let expected = crate::input::RpcV2CborDenseMapsInput {
|
2070 2176 | dense_number_map: ::std::option::Option::Some({
|
2071 2177 | let mut ret = ::std::collections::HashMap::new();
|
2072 2178 | ret.insert("x".to_owned(), 0);
|
2073 2179 | ret
|
2074 2180 | }),
|
2075 2181 | dense_boolean_map: ::std::option::Option::Some({
|
2076 2182 | let mut ret = ::std::collections::HashMap::new();
|
2077 2183 | ret.insert("x".to_owned(), false);
|
2078 2184 | ret
|
2079 2185 | }),
|
2080 2186 | dense_struct_map: ::std::option::Option::None,
|
2081 2187 | dense_string_map: ::std::option::Option::None,
|
2082 2188 | dense_set_map: ::std::option::Option::None,
|
2083 2189 | };
|
2084 2190 | ::pretty_assertions::assert_eq!(input, expected);
|
2085 2191 | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2086 2192 | dense_struct_map: ::std::option::Option::None,
|
2087 2193 | dense_number_map: ::std::option::Option::None,
|
2088 2194 | dense_boolean_map: ::std::option::Option::None,
|
2089 2195 | dense_string_map: ::std::option::Option::None,
|
2090 2196 | dense_set_map: ::std::option::Option::None,
|
2091 2197 | };
|
2092 2198 | Ok(output)
|
2093 2199 | };
|
2094 2200 | sender.send(()).await.expect("receiver dropped early");
|
2095 2201 | result
|
2096 2202 | }
|
2097 2203 | })
|
2098 2204 | .build_unchecked();
|
2099 2205 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2100 2206 | .await
|
2101 2207 | .expect("unable to make an HTTP request");
|
2102 2208 | assert!(
|
2103 2209 | receiver.recv().await.is_some(),
|
2104 2210 | "we expected operation handler to be invoked but it was not entered"
|
2105 2211 | );
|
2106 2212 | }
|
2107 2213 |
|
2108 2214 | /// A request that contains a dense map of sets.
|
2109 2215 | /// Test ID: RpcV2CborSerializesDenseSetMap
|
2110 2216 | #[::tokio::test]
|
2111 2217 | #[::tracing_test::traced_test]
|
2112 2218 | async fn rpc_v2_cbor_serializes_dense_set_map_request() {
|
2113 2219 | #[allow(unused_mut)]
|
2114 - | let mut http_request = http::Request::builder()
|
2220 + | let mut http_request = ::http_1x::Request::builder()
|
2115 2221 | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
2116 2222 | .method("POST")
|
2117 2223 | .header("Accept", "application/cbor")
|
2118 2224 | .header("Content-Type", "application/cbor")
|
2119 2225 | .header("smithy-protocol", "rpc-v2-cbor")
|
2120 - | .body(::aws_smithy_http_server::body::Body::from(
|
2121 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2226 + | .body(::aws_smithy_http_server::body::boxed(
|
2227 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2228 + | &::aws_smithy_protocol_test::decode_body_data(
|
2122 2229 | "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi".as_bytes(),
|
2123 2230 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2231 + | ),
|
2124 2232 | )),
|
2125 2233 | ))
|
2126 2234 | .unwrap();
|
2127 2235 | #[allow(unused_mut)]
|
2128 2236 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2129 2237 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2130 - | let service =
|
2131 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2238 + | let service = crate::service::RpcV2Protocol::builder::<
|
2239 + | ::aws_smithy_http_server::body::BoxBody,
|
2240 + | _,
|
2241 + | _,
|
2242 + | _,
|
2243 + | >(config)
|
2132 2244 | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
2133 2245 | let sender = sender.clone();
|
2134 2246 | async move {
|
2135 2247 | let result = {
|
2136 2248 | let expected = crate::input::RpcV2CborDenseMapsInput {
|
2137 2249 | dense_set_map: ::std::option::Option::Some({
|
2138 2250 | let mut ret = ::std::collections::HashMap::new();
|
2139 2251 | ret.insert(
|
2140 2252 | "x".to_owned(),
|
2141 2253 | vec![].try_into().expect("this is only used in tests"),
|
2533 2657 | "we expected operation handler to be invoked but it was not entered"
|
2534 2658 | );
|
2535 2659 | }
|
2536 2660 |
|
2537 2661 | /// Serializes empty JSON lists
|
2538 2662 | /// Test ID: RpcV2CborListsEmpty
|
2539 2663 | #[::tokio::test]
|
2540 2664 | #[::tracing_test::traced_test]
|
2541 2665 | async fn rpc_v2_cbor_lists_empty_request() {
|
2542 2666 | #[allow(unused_mut)]
|
2543 - | let mut http_request = http::Request::builder()
|
2667 + | let mut http_request = ::http_1x::Request::builder()
|
2544 2668 | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2545 2669 | .method("POST")
|
2546 2670 | .header("Accept", "application/cbor")
|
2547 2671 | .header("Content-Type", "application/cbor")
|
2548 2672 | .header("smithy-protocol", "rpc-v2-cbor")
|
2549 - | .body(::aws_smithy_http_server::body::Body::from(
|
2550 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2673 + | .body(::aws_smithy_http_server::body::boxed(
|
2674 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2675 + | &::aws_smithy_protocol_test::decode_body_data(
|
2551 2676 | "v2pzdHJpbmdMaXN0n///".as_bytes(),
|
2552 2677 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2678 + | ),
|
2553 2679 | )),
|
2554 2680 | ))
|
2555 2681 | .unwrap();
|
2556 2682 | #[allow(unused_mut)]
|
2557 2683 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2558 2684 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2559 - | let service =
|
2560 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2685 + | let service = crate::service::RpcV2Protocol::builder::<
|
2686 + | ::aws_smithy_http_server::body::BoxBody,
|
2687 + | _,
|
2688 + | _,
|
2689 + | _,
|
2690 + | >(config)
|
2561 2691 | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
2562 2692 | let sender = sender.clone();
|
2563 2693 | async move {
|
2564 2694 | let result = {
|
2565 2695 | let expected = crate::input::RpcV2CborListsInput {
|
2566 2696 | string_list: ::std::option::Option::Some(vec![]),
|
2567 2697 | string_set: ::std::option::Option::None,
|
2568 2698 | integer_list: ::std::option::Option::None,
|
2569 2699 | boolean_list: ::std::option::Option::None,
|
2570 2700 | timestamp_list: ::std::option::Option::None,
|
2571 2701 | enum_list: ::std::option::Option::None,
|
2572 2702 | int_enum_list: ::std::option::Option::None,
|
2573 2703 | nested_string_list: ::std::option::Option::None,
|
2574 2704 | structure_list: ::std::option::Option::None,
|
2575 2705 | blob_list: ::std::option::Option::None,
|
2576 2706 | };
|
2577 2707 | ::pretty_assertions::assert_eq!(input, expected);
|
2578 2708 | let output = crate::output::RpcV2CborListsOutput {
|
2579 2709 | string_list: ::std::option::Option::None,
|
2580 2710 | string_set: ::std::option::Option::None,
|
2581 2711 | integer_list: ::std::option::Option::None,
|
2582 2712 | boolean_list: ::std::option::Option::None,
|
2583 2713 | timestamp_list: ::std::option::Option::None,
|
2584 2714 | enum_list: ::std::option::Option::None,
|
2585 2715 | int_enum_list: ::std::option::Option::None,
|
2586 2716 | nested_string_list: ::std::option::Option::None,
|
2587 2717 | structure_list: ::std::option::Option::None,
|
2588 2718 | blob_list: ::std::option::Option::None,
|
2589 2719 | };
|
2590 2720 | Ok(output)
|
2591 2721 | };
|
2592 2722 | sender.send(()).await.expect("receiver dropped early");
|
2593 2723 | result
|
2594 2724 | }
|
2595 2725 | })
|
2596 2726 | .build_unchecked();
|
2597 2727 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2598 2728 | .await
|
2599 2729 | .expect("unable to make an HTTP request");
|
2600 2730 | assert!(
|
2601 2731 | receiver.recv().await.is_some(),
|
2602 2732 | "we expected operation handler to be invoked but it was not entered"
|
2603 2733 | );
|
2604 2734 | }
|
2605 2735 |
|
2606 2736 | /// Serializes empty JSON definite length lists
|
2607 2737 | /// Test ID: RpcV2CborListsEmptyUsingDefiniteLength
|
2608 2738 | #[::tokio::test]
|
2609 2739 | #[::tracing_test::traced_test]
|
2610 2740 | async fn rpc_v2_cbor_lists_empty_using_definite_length_request() {
|
2611 2741 | #[allow(unused_mut)]
|
2612 - | let mut http_request = http::Request::builder()
|
2742 + | let mut http_request = ::http_1x::Request::builder()
|
2613 2743 | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2614 2744 | .method("POST")
|
2615 2745 | .header("Accept", "application/cbor")
|
2616 2746 | .header("Content-Type", "application/cbor")
|
2617 2747 | .header("smithy-protocol", "rpc-v2-cbor")
|
2618 - | .body(::aws_smithy_http_server::body::Body::from(
|
2619 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2748 + | .body(::aws_smithy_http_server::body::boxed(
|
2749 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2750 + | &::aws_smithy_protocol_test::decode_body_data(
|
2620 2751 | "oWpzdHJpbmdMaXN0gA==".as_bytes(),
|
2621 2752 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2753 + | ),
|
2622 2754 | )),
|
2623 2755 | ))
|
2624 2756 | .unwrap();
|
2625 2757 | #[allow(unused_mut)]
|
2626 2758 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2627 2759 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2628 - | let service =
|
2629 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2760 + | let service = crate::service::RpcV2Protocol::builder::<
|
2761 + | ::aws_smithy_http_server::body::BoxBody,
|
2762 + | _,
|
2763 + | _,
|
2764 + | _,
|
2765 + | >(config)
|
2630 2766 | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
2631 2767 | let sender = sender.clone();
|
2632 2768 | async move {
|
2633 2769 | let result = {
|
2634 2770 | let expected = crate::input::RpcV2CborListsInput {
|
2635 2771 | string_list: ::std::option::Option::Some(vec![]),
|
2636 2772 | string_set: ::std::option::Option::None,
|
2637 2773 | integer_list: ::std::option::Option::None,
|
2638 2774 | boolean_list: ::std::option::Option::None,
|
2639 2775 | timestamp_list: ::std::option::Option::None,
|
2640 2776 | enum_list: ::std::option::Option::None,
|
2641 2777 | int_enum_list: ::std::option::Option::None,
|
2642 2778 | nested_string_list: ::std::option::Option::None,
|
2643 2779 | structure_list: ::std::option::Option::None,
|
2644 2780 | blob_list: ::std::option::Option::None,
|
2645 2781 | };
|
2646 2782 | ::pretty_assertions::assert_eq!(input, expected);
|
2647 2783 | let output = crate::output::RpcV2CborListsOutput {
|
2648 2784 | string_list: ::std::option::Option::None,
|
2649 2785 | string_set: ::std::option::Option::None,
|
2650 2786 | integer_list: ::std::option::Option::None,
|
2651 2787 | boolean_list: ::std::option::Option::None,
|
2652 2788 | timestamp_list: ::std::option::Option::None,
|
2653 2789 | enum_list: ::std::option::Option::None,
|
2654 2790 | int_enum_list: ::std::option::Option::None,
|
2655 2791 | nested_string_list: ::std::option::Option::None,
|
2656 2792 | structure_list: ::std::option::Option::None,
|
2657 2793 | blob_list: ::std::option::Option::None,
|
2658 2794 | };
|
2659 2795 | Ok(output)
|
2660 2796 | };
|
2661 2797 | sender.send(()).await.expect("receiver dropped early");
|
2662 2798 | result
|
2663 2799 | }
|
2664 2800 | })
|
2665 2801 | .build_unchecked();
|
2666 2802 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2667 2803 | .await
|
2668 2804 | .expect("unable to make an HTTP request");
|
2669 2805 | assert!(
|
2670 2806 | receiver.recv().await.is_some(),
|
2671 2807 | "we expected operation handler to be invoked but it was not entered"
|
2672 2808 | );
|
2673 2809 | }
|
2674 2810 |
|
2675 2811 | /// Can deserialize indefinite length text strings inside an indefinite length list
|
2676 2812 | /// Test ID: RpcV2CborIndefiniteStringInsideIndefiniteList
|
2677 2813 | #[::tokio::test]
|
2678 2814 | #[::tracing_test::traced_test]
|
2679 2815 | async fn rpc_v2_cbor_indefinite_string_inside_indefinite_list_request() {
|
2680 2816 | #[allow(unused_mut)]
|
2681 - | let mut http_request = http::Request::builder()
|
2817 + | let mut http_request = ::http_1x::Request::builder()
|
2682 2818 | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2683 2819 | .method("POST")
|
2684 2820 | .header("Accept", "application/cbor")
|
2685 2821 | .header("Content-Type", "application/cbor")
|
2686 2822 | .header("smithy-protocol", "rpc-v2-cbor")
|
2687 - | .body(::aws_smithy_http_server::body::Body::from(
|
2823 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
2688 2824 | ::bytes::Bytes::copy_from_slice(
|
2689 2825 | &::aws_smithy_protocol_test::decode_body_data("v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n//8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2690 2826 | )
|
2691 - | )).unwrap();
|
2827 + | ))).unwrap();
|
2692 2828 | #[allow(unused_mut)]
|
2693 2829 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2694 2830 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2695 - | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
2696 - | config,
|
2697 - | )
|
2831 + | let service = crate::service::RpcV2Protocol::builder::<
|
2832 + | ::aws_smithy_http_server::body::BoxBody,
|
2833 + | _,
|
2834 + | _,
|
2835 + | _,
|
2836 + | >(config)
|
2698 2837 | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
2699 2838 | let sender = sender.clone();
|
2700 2839 | async move {
|
2701 2840 | let result = {
|
2702 2841 | let expected = crate::input::RpcV2CborListsInput {
|
2703 2842 | string_list: ::std::option::Option::Some(vec![
|
2704 2843 | "An example indefinite string, which will be chunked, on each comma"
|
2705 2844 | .to_owned(),
|
2706 2845 | "Another example indefinite string with only one chunk".to_owned(),
|
2707 2846 | "This is a plain string".to_owned(),
|
2708 2847 | ]),
|
2709 2848 | string_set: ::std::option::Option::None,
|
2710 2849 | integer_list: ::std::option::Option::None,
|
2711 2850 | boolean_list: ::std::option::Option::None,
|
2712 2851 | timestamp_list: ::std::option::Option::None,
|
2713 2852 | enum_list: ::std::option::Option::None,
|
2714 2853 | int_enum_list: ::std::option::Option::None,
|
2715 2854 | nested_string_list: ::std::option::Option::None,
|
2716 2855 | structure_list: ::std::option::Option::None,
|
2717 2856 | blob_list: ::std::option::Option::None,
|
2718 2857 | };
|
2719 2858 | ::pretty_assertions::assert_eq!(input, expected);
|
2720 2859 | let output = crate::output::RpcV2CborListsOutput {
|
2721 2860 | string_list: ::std::option::Option::None,
|
2722 2861 | string_set: ::std::option::Option::None,
|
2723 2862 | integer_list: ::std::option::Option::None,
|
2724 2863 | boolean_list: ::std::option::Option::None,
|
2725 2864 | timestamp_list: ::std::option::Option::None,
|
2726 2865 | enum_list: ::std::option::Option::None,
|
2727 2866 | int_enum_list: ::std::option::Option::None,
|
2728 2867 | nested_string_list: ::std::option::Option::None,
|
2729 2868 | structure_list: ::std::option::Option::None,
|
2730 2869 | blob_list: ::std::option::Option::None,
|
2731 2870 | };
|
2732 2871 | Ok(output)
|
2733 2872 | };
|
2734 2873 | sender.send(()).await.expect("receiver dropped early");
|
2735 2874 | result
|
2736 2875 | }
|
2737 2876 | })
|
2738 2877 | .build_unchecked();
|
2739 2878 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2740 2879 | .await
|
2741 2880 | .expect("unable to make an HTTP request");
|
2742 2881 | assert!(
|
2743 2882 | receiver.recv().await.is_some(),
|
2744 2883 | "we expected operation handler to be invoked but it was not entered"
|
2745 2884 | );
|
2746 2885 | }
|
2747 2886 |
|
2748 2887 | /// Can deserialize indefinite length text strings inside a definite length list
|
2749 2888 | /// Test ID: RpcV2CborIndefiniteStringInsideDefiniteList
|
2750 2889 | #[::tokio::test]
|
2751 2890 | #[::tracing_test::traced_test]
|
2752 2891 | async fn rpc_v2_cbor_indefinite_string_inside_definite_list_request() {
|
2753 2892 | #[allow(unused_mut)]
|
2754 - | let mut http_request = http::Request::builder()
|
2893 + | let mut http_request = ::http_1x::Request::builder()
|
2755 2894 | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2756 2895 | .method("POST")
|
2757 2896 | .header("Accept", "application/cbor")
|
2758 2897 | .header("Content-Type", "application/cbor")
|
2759 2898 | .header("smithy-protocol", "rpc-v2-cbor")
|
2760 - | .body(::aws_smithy_http_server::body::Body::from(
|
2899 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
2761 2900 | ::bytes::Bytes::copy_from_slice(
|
2762 2901 | &::aws_smithy_protocol_test::decode_body_data("oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2763 2902 | )
|
2764 - | )).unwrap();
|
2903 + | ))).unwrap();
|
2765 2904 | #[allow(unused_mut)]
|
2766 2905 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2767 2906 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2768 - | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
2769 - | config,
|
2770 - | )
|
2907 + | let service = crate::service::RpcV2Protocol::builder::<
|
2908 + | ::aws_smithy_http_server::body::BoxBody,
|
2909 + | _,
|
2910 + | _,
|
2911 + | _,
|
2912 + | >(config)
|
2771 2913 | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
2772 2914 | let sender = sender.clone();
|
2773 2915 | async move {
|
2774 2916 | let result = {
|
2775 2917 | let expected = crate::input::RpcV2CborListsInput {
|
2776 2918 | string_list: ::std::option::Option::Some(vec![
|
2777 2919 | "An example indefinite string, which will be chunked, on each comma"
|
2778 2920 | .to_owned(),
|
2779 2921 | "Another example indefinite string with only one chunk".to_owned(),
|
2780 2922 | "This is a plain string".to_owned(),
|
2859 3001 | },
|
2860 3002 | ]),
|
2861 3003 | blob_list: ::std::option::Option::Some(vec![
|
2862 3004 | ::aws_smithy_types::Blob::new("foo"),
|
2863 3005 | ::aws_smithy_types::Blob::new("bar"),
|
2864 3006 | ]),
|
2865 3007 | };
|
2866 3008 | use ::aws_smithy_http_server::response::IntoResponse;
|
2867 3009 | let http_response = output.into_response();
|
2868 3010 | ::pretty_assertions::assert_eq!(
|
2869 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3011 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2870 3012 | http_response.status()
|
2871 3013 | );
|
2872 3014 | let expected_headers = [
|
2873 3015 | ("Content-Type", "application/cbor"),
|
2874 3016 | ("smithy-protocol", "rpc-v2-cbor"),
|
2875 3017 | ];
|
2876 3018 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2877 3019 | http_response.headers(),
|
2878 3020 | expected_headers,
|
2879 3021 | ));
|
2880 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3022 + | use ::http_body_util::BodyExt;
|
3023 + | let body = http_response
|
3024 + | .into_body()
|
3025 + | .collect()
|
2881 3026 | .await
|
2882 - | .expect("unable to extract body to bytes");
|
3027 + | .expect("unable to collect body")
|
3028 + | .to_bytes();
|
2883 3029 | ::aws_smithy_protocol_test::assert_ok(
|
2884 3030 | ::aws_smithy_protocol_test::validate_body(&body, "v2pzdHJpbmdMaXN0n2Nmb29jYmFy/2lzdHJpbmdTZXSfY2Zvb2NiYXL/a2ludGVnZXJMaXN0nwEC/2tib29sZWFuTGlzdJ/19P9tdGltZXN0YW1wTGlzdJ/B+0HU1/vzgAAAwftB1Nf784AAAP9oZW51bUxpc3SfY0Zvb2Ew/2tpbnRFbnVtTGlzdJ8BAv9wbmVzdGVkU3RyaW5nTGlzdJ+fY2Zvb2NiYXL/n2NiYXpjcXV4//9tc3RydWN0dXJlTGlzdJ+/YWFhMWFiYTL/v2FhYTNhYmE0//9oYmxvYkxpc3SfQ2Zvb0NiYXL//w==", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2885 3031 | );
|
2886 3032 | }
|
2887 3033 |
|
2888 3034 | /// Serializes empty RpcV2 Cbor lists
|
2889 3035 | /// Test ID: RpcV2CborListsEmpty
|
2890 3036 | #[::tokio::test]
|
2891 3037 | #[::tracing_test::traced_test]
|
2892 3038 | async fn rpc_v2_cbor_lists_empty_response() {
|
2893 3039 | let output = crate::output::RpcV2CborListsOutput {
|
2894 3040 | string_list: ::std::option::Option::Some(vec![]),
|
2895 3041 | string_set: ::std::option::Option::None,
|
2896 3042 | integer_list: ::std::option::Option::None,
|
2897 3043 | boolean_list: ::std::option::Option::None,
|
2898 3044 | timestamp_list: ::std::option::Option::None,
|
2899 3045 | enum_list: ::std::option::Option::None,
|
2900 3046 | int_enum_list: ::std::option::Option::None,
|
2901 3047 | nested_string_list: ::std::option::Option::None,
|
2902 3048 | structure_list: ::std::option::Option::None,
|
2903 3049 | blob_list: ::std::option::Option::None,
|
2904 3050 | };
|
2905 3051 | use ::aws_smithy_http_server::response::IntoResponse;
|
2906 3052 | let http_response = output.into_response();
|
2907 3053 | ::pretty_assertions::assert_eq!(
|
2908 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3054 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2909 3055 | http_response.status()
|
2910 3056 | );
|
2911 3057 | let expected_headers = [
|
2912 3058 | ("Content-Type", "application/cbor"),
|
2913 3059 | ("smithy-protocol", "rpc-v2-cbor"),
|
2914 3060 | ];
|
2915 3061 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2916 3062 | http_response.headers(),
|
2917 3063 | expected_headers,
|
2918 3064 | ));
|
2919 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3065 + | use ::http_body_util::BodyExt;
|
3066 + | let body = http_response
|
3067 + | .into_body()
|
3068 + | .collect()
|
2920 3069 | .await
|
2921 - | .expect("unable to extract body to bytes");
|
3070 + | .expect("unable to collect body")
|
3071 + | .to_bytes();
|
2922 3072 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2923 3073 | &body,
|
2924 3074 | "v2pzdHJpbmdMaXN0n///",
|
2925 3075 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2926 3076 | ));
|
2927 3077 | }
|
2928 3078 | }
|
2929 3079 |
|
2930 3080 | ::pin_project_lite::pin_project! {
|
2931 3081 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2932 3082 | /// [`SimpleScalarPropertiesInput`](crate::input::SimpleScalarPropertiesInput) using modelled bindings.
|
2933 3083 | pub struct SimpleScalarPropertiesInputFuture {
|
2934 3084 | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SimpleScalarPropertiesInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
2935 3085 | }
|
2936 3086 | }
|
2937 3087 |
|
2938 3088 | impl std::future::Future for SimpleScalarPropertiesInputFuture {
|
2939 3089 | type Output = Result<
|
2940 3090 | crate::input::SimpleScalarPropertiesInput,
|
2941 3091 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
2942 3092 | >;
|
2943 3093 |
|
2944 3094 | fn poll(
|
2945 3095 | self: std::pin::Pin<&mut Self>,
|
2946 3096 | cx: &mut std::task::Context<'_>,
|
2947 3097 | ) -> std::task::Poll<Self::Output> {
|
2948 3098 | let this = self.project();
|
2949 3099 | this.inner.as_mut().poll(cx)
|
2950 3100 | }
|
2951 3101 | }
|
2952 3102 |
|
2953 3103 | impl<B>
|
2954 3104 | ::aws_smithy_http_server::request::FromRequest<
|
2955 3105 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2956 3106 | B,
|
2957 3107 | > for crate::input::SimpleScalarPropertiesInput
|
2958 3108 | where
|
2959 3109 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
2960 3110 | B: 'static,
|
2961 3111 |
|
2962 3112 | B::Data: Send,
|
2963 3113 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
2964 3114 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
2965 3115 | {
|
2966 3116 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
2967 3117 | type Future = SimpleScalarPropertiesInputFuture;
|
2968 3118 |
|
2969 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
3119 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
2970 3120 | let fut = async move {
|
2971 3121 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
2972 3122 | request.headers(),
|
2973 3123 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
2974 3124 | ) {
|
2975 3125 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
2976 3126 | }
|
2977 3127 | crate::protocol_serde::shape_simple_scalar_properties::de_simple_scalar_properties_http_request(request)
|
2978 3128 | .await
|
2979 3129 | };
|
2980 3130 | use ::futures_util::future::TryFutureExt;
|
2981 3131 | let fut = fut.map_err(
|
2982 3132 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
2983 3133 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2984 3134 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
2985 3135 | e,
|
2986 3136 | )
|
2987 3137 | },
|
2988 3138 | );
|
2989 3139 | SimpleScalarPropertiesInputFuture {
|
2990 3140 | inner: Box::pin(fut),
|
2991 3141 | }
|
2992 3142 | }
|
2993 3143 | }
|
2994 3144 | impl
|
2995 3145 | ::aws_smithy_http_server::response::IntoResponse<
|
2996 3146 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2997 3147 | > for crate::output::SimpleScalarPropertiesOutput
|
2998 3148 | {
|
2999 3149 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
3000 3150 | match crate::protocol_serde::shape_simple_scalar_properties::ser_simple_scalar_properties_http_response(self) {
|
3001 3151 | Ok(response) => response,
|
3002 3152 | Err(e) => {
|
3003 3153 | ::tracing::error!(error = %e, "failed to serialize response");
|
3004 3154 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
3005 3155 | }
|
3006 3156 | }
|
3007 3157 | }
|
3008 3158 | }
|
3009 3159 |
|
3010 3160 | #[allow(unreachable_code, unused_variables)]
|
3011 3161 | #[cfg(test)]
|
3012 3162 | mod simple_scalar_properties_test {
|
3013 3163 |
|
3014 3164 | /// Serializes simple scalar properties
|
3015 3165 | /// Test ID: RpcV2CborSimpleScalarProperties
|
3016 3166 | #[::tokio::test]
|
3017 3167 | #[::tracing_test::traced_test]
|
3018 3168 | async fn rpc_v2_cbor_simple_scalar_properties_request() {
|
3019 3169 | #[allow(unused_mut)]
|
3020 - | let mut http_request = http::Request::builder()
|
3170 + | let mut http_request = ::http_1x::Request::builder()
|
3021 3171 | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3022 3172 | .method("POST")
|
3023 3173 | .header("Accept", "application/cbor")
|
3024 3174 | .header("Content-Type", "application/cbor")
|
3025 3175 | .header("smithy-protocol", "rpc-v2-cbor")
|
3026 - | .body(::aws_smithy_http_server::body::Body::from(
|
3176 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
3027 3177 | ::bytes::Bytes::copy_from_slice(
|
3028 3178 | &::aws_smithy_protocol_test::decode_body_data("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3029 3179 | )
|
3030 - | )).unwrap();
|
3180 + | ))).unwrap();
|
3031 3181 | #[allow(unused_mut)]
|
3032 3182 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3033 3183 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3034 - | let service =
|
3035 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3036 - | .simple_scalar_properties(
|
3037 - | move |input: crate::input::SimpleScalarPropertiesInput| {
|
3184 + | let service = crate::service::RpcV2Protocol::builder::<
|
3185 + | ::aws_smithy_http_server::body::BoxBody,
|
3186 + | _,
|
3187 + | _,
|
3188 + | _,
|
3189 + | >(config)
|
3190 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
3038 3191 | let sender = sender.clone();
|
3039 3192 | async move {
|
3040 3193 | let result = {
|
3041 3194 | use ::aws_smithy_protocol_test::FloatEquals;
|
3042 3195 | let expected = crate::input::SimpleScalarPropertiesInput {
|
3043 3196 | byte_value: ::std::option::Option::Some(5),
|
3044 3197 | double_value: ::std::option::Option::Some(1.889_f64),
|
3045 3198 | false_boolean_value: ::std::option::Option::Some(false),
|
3046 3199 | float_value: ::std::option::Option::Some(7.625_f32),
|
3047 3200 | integer_value: ::std::option::Option::Some(256),
|
3048 3201 | long_value: ::std::option::Option::Some(9873),
|
3049 3202 | short_value: ::std::option::Option::Some(9898),
|
3050 3203 | string_value: ::std::option::Option::Some("simple".to_owned()),
|
3051 3204 | true_boolean_value: ::std::option::Option::Some(true),
|
3052 - | blob_value: ::std::option::Option::Some(
|
3053 - | ::aws_smithy_types::Blob::new("foo"),
|
3054 - | ),
|
3205 + | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new(
|
3206 + | "foo",
|
3207 + | )),
|
3055 3208 | };
|
3056 3209 | ::pretty_assertions::assert_eq!(
|
3057 3210 | input.true_boolean_value,
|
3058 3211 | expected.true_boolean_value,
|
3059 3212 | "Unexpected value for `true_boolean_value`"
|
3060 3213 | );
|
3061 3214 | ::pretty_assertions::assert_eq!(
|
3062 3215 | input.false_boolean_value,
|
3063 3216 | expected.false_boolean_value,
|
3064 3217 | "Unexpected value for `false_boolean_value`"
|
4375 4557 | long_value: ::std::option::Option::None,
|
4376 4558 | short_value: ::std::option::Option::None,
|
4377 4559 | string_value: ::std::option::Option::None,
|
4378 4560 | blob_value: ::std::option::Option::None,
|
4379 4561 | };
|
4380 4562 | output
|
4381 4563 | };
|
4382 4564 | sender.send(()).await.expect("receiver dropped early");
|
4383 4565 | result
|
4384 4566 | }
|
4385 - | },
|
4386 - | )
|
4567 + | })
|
4387 4568 | .build_unchecked();
|
4388 4569 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4389 4570 | .await
|
4390 4571 | .expect("unable to make an HTTP request");
|
4391 4572 | assert!(
|
4392 4573 | receiver.recv().await.is_some(),
|
4393 4574 | "we expected operation handler to be invoked but it was not entered"
|
4394 4575 | );
|
4395 4576 | }
|
4396 4577 |
|
4397 4578 | /// Serializes simple scalar properties
|
4398 4579 | /// Test ID: RpcV2CborSimpleScalarProperties
|
4399 4580 | #[::tokio::test]
|
4400 4581 | #[::tracing_test::traced_test]
|
4401 4582 | async fn rpc_v2_cbor_simple_scalar_properties_response() {
|
4402 4583 | let output = crate::output::SimpleScalarPropertiesOutput {
|
4403 4584 | true_boolean_value: ::std::option::Option::Some(true),
|
4404 4585 | false_boolean_value: ::std::option::Option::Some(false),
|
4405 4586 | byte_value: ::std::option::Option::Some(5),
|
4406 4587 | double_value: ::std::option::Option::Some(1.889_f64),
|
4407 4588 | float_value: ::std::option::Option::Some(7.625_f32),
|
4408 4589 | integer_value: ::std::option::Option::Some(256),
|
4409 4590 | short_value: ::std::option::Option::Some(9898),
|
4410 4591 | string_value: ::std::option::Option::Some("simple".to_owned()),
|
4411 4592 | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new("foo")),
|
4412 4593 | long_value: ::std::option::Option::None,
|
4413 4594 | };
|
4414 4595 | use ::aws_smithy_http_server::response::IntoResponse;
|
4415 4596 | let http_response = output.into_response();
|
4416 4597 | ::pretty_assertions::assert_eq!(
|
4417 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4598 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4418 4599 | http_response.status()
|
4419 4600 | );
|
4420 4601 | let expected_headers = [
|
4421 4602 | ("Content-Type", "application/cbor"),
|
4422 4603 | ("smithy-protocol", "rpc-v2-cbor"),
|
4423 4604 | ];
|
4424 4605 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4425 4606 | http_response.headers(),
|
4426 4607 | expected_headers,
|
4427 4608 | ));
|
4428 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4609 + | use ::http_body_util::BodyExt;
|
4610 + | let body = http_response
|
4611 + | .into_body()
|
4612 + | .collect()
|
4429 4613 | .await
|
4430 - | .expect("unable to extract body to bytes");
|
4614 + | .expect("unable to collect body")
|
4615 + | .to_bytes();
|
4431 4616 | ::aws_smithy_protocol_test::assert_ok(
|
4432 4617 | ::aws_smithy_protocol_test::validate_body(&body, "v3B0cnVlQm9vbGVhblZhbHVl9XFmYWxzZUJvb2xlYW5WYWx1ZfRpYnl0ZVZhbHVlBWtkb3VibGVWYWx1Zfs//jlYEGJN02pmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAanNob3J0VmFsdWUZJqprc3RyaW5nVmFsdWVmc2ltcGxlaWJsb2JWYWx1ZUNmb2//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4433 4618 | );
|
4434 4619 | }
|
4435 4620 |
|
4436 4621 | /// RpcV2 Cbor should not serialize null structure values
|
4437 4622 | /// Test ID: RpcV2CborServerDoesntSerializeNullStructureValues
|
4438 4623 | #[::tokio::test]
|
4439 4624 | #[::tracing_test::traced_test]
|
4440 4625 | async fn rpc_v2_cbor_server_doesnt_serialize_null_structure_values_response() {
|
4441 4626 | let output = crate::output::SimpleScalarPropertiesOutput {
|
4442 4627 | string_value: ::std::option::Option::None,
|
4443 4628 | true_boolean_value: ::std::option::Option::None,
|
4444 4629 | false_boolean_value: ::std::option::Option::None,
|
4445 4630 | byte_value: ::std::option::Option::None,
|
4446 4631 | double_value: ::std::option::Option::None,
|
4447 4632 | float_value: ::std::option::Option::None,
|
4448 4633 | integer_value: ::std::option::Option::None,
|
4449 4634 | long_value: ::std::option::Option::None,
|
4450 4635 | short_value: ::std::option::Option::None,
|
4451 4636 | blob_value: ::std::option::Option::None,
|
4452 4637 | };
|
4453 4638 | use ::aws_smithy_http_server::response::IntoResponse;
|
4454 4639 | let http_response = output.into_response();
|
4455 4640 | ::pretty_assertions::assert_eq!(
|
4456 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4641 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4457 4642 | http_response.status()
|
4458 4643 | );
|
4459 4644 | let expected_headers = [
|
4460 4645 | ("Content-Type", "application/cbor"),
|
4461 4646 | ("smithy-protocol", "rpc-v2-cbor"),
|
4462 4647 | ];
|
4463 4648 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4464 4649 | http_response.headers(),
|
4465 4650 | expected_headers,
|
4466 4651 | ));
|
4467 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4652 + | use ::http_body_util::BodyExt;
|
4653 + | let body = http_response
|
4654 + | .into_body()
|
4655 + | .collect()
|
4468 4656 | .await
|
4469 - | .expect("unable to extract body to bytes");
|
4657 + | .expect("unable to collect body")
|
4658 + | .to_bytes();
|
4470 4659 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4471 4660 | &body,
|
4472 4661 | "v/8=",
|
4473 4662 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4474 4663 | ));
|
4475 4664 | }
|
4476 4665 |
|
4477 4666 | /// Supports handling NaN float values.
|
4478 4667 | /// Test ID: RpcV2CborSupportsNaNFloatOutputs
|
4479 4668 | #[::tokio::test]
|
4480 4669 | #[::tracing_test::traced_test]
|
4481 4670 | async fn rpc_v2_cbor_supports_na_n_float_outputs_response() {
|
4482 4671 | let output = crate::output::SimpleScalarPropertiesOutput {
|
4483 4672 | double_value: ::std::option::Option::Some(
|
4484 4673 | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
4485 4674 | .expect("invalid string for number"),
|
4486 4675 | ),
|
4487 4676 | float_value: ::std::option::Option::Some(
|
4488 4677 | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
4489 4678 | .expect("invalid string for number"),
|
4490 4679 | ),
|
4491 4680 | true_boolean_value: ::std::option::Option::None,
|
4492 4681 | false_boolean_value: ::std::option::Option::None,
|
4493 4682 | byte_value: ::std::option::Option::None,
|
4494 4683 | integer_value: ::std::option::Option::None,
|
4495 4684 | long_value: ::std::option::Option::None,
|
4496 4685 | short_value: ::std::option::Option::None,
|
4497 4686 | string_value: ::std::option::Option::None,
|
4498 4687 | blob_value: ::std::option::Option::None,
|
4499 4688 | };
|
4500 4689 | use ::aws_smithy_http_server::response::IntoResponse;
|
4501 4690 | let http_response = output.into_response();
|
4502 4691 | ::pretty_assertions::assert_eq!(
|
4503 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4692 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4504 4693 | http_response.status()
|
4505 4694 | );
|
4506 4695 | let expected_headers = [
|
4507 4696 | ("Content-Type", "application/cbor"),
|
4508 4697 | ("smithy-protocol", "rpc-v2-cbor"),
|
4509 4698 | ];
|
4510 4699 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4511 4700 | http_response.headers(),
|
4512 4701 | expected_headers,
|
4513 4702 | ));
|
4514 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4703 + | use ::http_body_util::BodyExt;
|
4704 + | let body = http_response
|
4705 + | .into_body()
|
4706 + | .collect()
|
4515 4707 | .await
|
4516 - | .expect("unable to extract body to bytes");
|
4708 + | .expect("unable to collect body")
|
4709 + | .to_bytes();
|
4517 4710 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4518 4711 | &body,
|
4519 4712 | "v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/",
|
4520 4713 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4521 4714 | ));
|
4522 4715 | }
|
4523 4716 |
|
4524 4717 | /// Supports handling Infinity float values.
|
4525 4718 | /// Test ID: RpcV2CborSupportsInfinityFloatOutputs
|
4526 4719 | #[::tokio::test]
|
4527 4720 | #[::tracing_test::traced_test]
|
4528 4721 | async fn rpc_v2_cbor_supports_infinity_float_outputs_response() {
|
4529 4722 | let output = crate::output::SimpleScalarPropertiesOutput {
|
4530 4723 | double_value: ::std::option::Option::Some(
|
4531 4724 | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
4532 4725 | .expect("invalid string for number"),
|
4533 4726 | ),
|
4534 4727 | float_value: ::std::option::Option::Some(
|
4535 4728 | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
4536 4729 | .expect("invalid string for number"),
|
4537 4730 | ),
|
4538 4731 | true_boolean_value: ::std::option::Option::None,
|
4539 4732 | false_boolean_value: ::std::option::Option::None,
|
4540 4733 | byte_value: ::std::option::Option::None,
|
4541 4734 | integer_value: ::std::option::Option::None,
|
4542 4735 | long_value: ::std::option::Option::None,
|
4543 4736 | short_value: ::std::option::Option::None,
|
4544 4737 | string_value: ::std::option::Option::None,
|
4545 4738 | blob_value: ::std::option::Option::None,
|
4546 4739 | };
|
4547 4740 | use ::aws_smithy_http_server::response::IntoResponse;
|
4548 4741 | let http_response = output.into_response();
|
4549 4742 | ::pretty_assertions::assert_eq!(
|
4550 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4743 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4551 4744 | http_response.status()
|
4552 4745 | );
|
4553 4746 | let expected_headers = [
|
4554 4747 | ("Content-Type", "application/cbor"),
|
4555 4748 | ("smithy-protocol", "rpc-v2-cbor"),
|
4556 4749 | ];
|
4557 4750 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4558 4751 | http_response.headers(),
|
4559 4752 | expected_headers,
|
4560 4753 | ));
|
4561 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4754 + | use ::http_body_util::BodyExt;
|
4755 + | let body = http_response
|
4756 + | .into_body()
|
4757 + | .collect()
|
4562 4758 | .await
|
4563 - | .expect("unable to extract body to bytes");
|
4759 + | .expect("unable to collect body")
|
4760 + | .to_bytes();
|
4564 4761 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4565 4762 | &body,
|
4566 4763 | "v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/",
|
4567 4764 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4568 4765 | ));
|
4569 4766 | }
|
4570 4767 |
|
4571 4768 | /// Supports handling Negative Infinity float values.
|
4572 4769 | /// Test ID: RpcV2CborSupportsNegativeInfinityFloatOutputs
|
4573 4770 | #[::tokio::test]
|
4574 4771 | #[::tracing_test::traced_test]
|
4575 4772 | async fn rpc_v2_cbor_supports_negative_infinity_float_outputs_response() {
|
4576 4773 | let output = crate::output::SimpleScalarPropertiesOutput {
|
4577 4774 | double_value: ::std::option::Option::Some(
|
4578 4775 | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
4579 4776 | .expect("invalid string for number"),
|
4580 4777 | ),
|
4581 4778 | float_value: ::std::option::Option::Some(
|
4582 4779 | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
4583 4780 | .expect("invalid string for number"),
|
4584 4781 | ),
|
4585 4782 | true_boolean_value: ::std::option::Option::None,
|
4586 4783 | false_boolean_value: ::std::option::Option::None,
|
4587 4784 | byte_value: ::std::option::Option::None,
|
4588 4785 | integer_value: ::std::option::Option::None,
|
4589 4786 | long_value: ::std::option::Option::None,
|
4590 4787 | short_value: ::std::option::Option::None,
|
4591 4788 | string_value: ::std::option::Option::None,
|
4592 4789 | blob_value: ::std::option::Option::None,
|
4593 4790 | };
|
4594 4791 | use ::aws_smithy_http_server::response::IntoResponse;
|
4595 4792 | let http_response = output.into_response();
|
4596 4793 | ::pretty_assertions::assert_eq!(
|
4597 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4794 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4598 4795 | http_response.status()
|
4599 4796 | );
|
4600 4797 | let expected_headers = [
|
4601 4798 | ("Content-Type", "application/cbor"),
|
4602 4799 | ("smithy-protocol", "rpc-v2-cbor"),
|
4603 4800 | ];
|
4604 4801 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4605 4802 | http_response.headers(),
|
4606 4803 | expected_headers,
|
4607 4804 | ));
|
4608 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4805 + | use ::http_body_util::BodyExt;
|
4806 + | let body = http_response
|
4807 + | .into_body()
|
4808 + | .collect()
|
4609 4809 | .await
|
4610 - | .expect("unable to extract body to bytes");
|
4810 + | .expect("unable to collect body")
|
4811 + | .to_bytes();
|
4611 4812 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4612 4813 | &body,
|
4613 4814 | "v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/",
|
4614 4815 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4615 4816 | ));
|
4616 4817 | }
|
4617 4818 | }
|
4618 4819 |
|
4619 4820 | ::pin_project_lite::pin_project! {
|
4620 4821 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4621 4822 | /// [`OptionalInputOutputInput`](crate::input::OptionalInputOutputInput) using modelled bindings.
|
4622 4823 | pub struct OptionalInputOutputInputFuture {
|
4623 4824 | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OptionalInputOutputInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4624 4825 | }
|
4625 4826 | }
|
4626 4827 |
|
4627 4828 | impl std::future::Future for OptionalInputOutputInputFuture {
|
4628 4829 | type Output = Result<
|
4629 4830 | crate::input::OptionalInputOutputInput,
|
4630 4831 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
4631 4832 | >;
|
4632 4833 |
|
4633 4834 | fn poll(
|
4634 4835 | self: std::pin::Pin<&mut Self>,
|
4635 4836 | cx: &mut std::task::Context<'_>,
|
4636 4837 | ) -> std::task::Poll<Self::Output> {
|
4637 4838 | let this = self.project();
|
4638 4839 | this.inner.as_mut().poll(cx)
|
4639 4840 | }
|
4640 4841 | }
|
4641 4842 |
|
4642 4843 | impl<B>
|
4643 4844 | ::aws_smithy_http_server::request::FromRequest<
|
4644 4845 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4645 4846 | B,
|
4646 4847 | > for crate::input::OptionalInputOutputInput
|
4647 4848 | where
|
4648 4849 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
4649 4850 | B: 'static,
|
4650 4851 |
|
4651 4852 | B::Data: Send,
|
4652 4853 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
4653 4854 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
4654 4855 | {
|
4655 4856 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
4656 4857 | type Future = OptionalInputOutputInputFuture;
|
4657 4858 |
|
4658 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
4859 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
4659 4860 | let fut = async move {
|
4660 4861 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
4661 4862 | request.headers(),
|
4662 4863 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
4663 4864 | ) {
|
4664 4865 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
4665 4866 | }
|
4666 4867 | crate::protocol_serde::shape_optional_input_output::de_optional_input_output_http_request(request)
|
4667 4868 | .await
|
4668 4869 | };
|
4669 4870 | use ::futures_util::future::TryFutureExt;
|
4670 4871 | let fut = fut.map_err(
|
4671 4872 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
4672 4873 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4673 4874 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
4674 4875 | e,
|
4675 4876 | )
|
4676 4877 | },
|
4677 4878 | );
|
4678 4879 | OptionalInputOutputInputFuture {
|
4679 4880 | inner: Box::pin(fut),
|
4680 4881 | }
|
4681 4882 | }
|
4682 4883 | }
|
4683 4884 | impl
|
4684 4885 | ::aws_smithy_http_server::response::IntoResponse<
|
4685 4886 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4686 4887 | > for crate::output::OptionalInputOutputOutput
|
4687 4888 | {
|
4688 4889 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
4689 4890 | match crate::protocol_serde::shape_optional_input_output::ser_optional_input_output_http_response(self) {
|
4690 4891 | Ok(response) => response,
|
4691 4892 | Err(e) => {
|
4692 4893 | ::tracing::error!(error = %e, "failed to serialize response");
|
4693 4894 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4694 4895 | }
|
4695 4896 | }
|
4696 4897 | }
|
4697 4898 | }
|
4698 4899 |
|
4699 4900 | #[allow(unreachable_code, unused_variables)]
|
4700 4901 | #[cfg(test)]
|
4701 4902 | mod optional_input_output_test {
|
4702 4903 |
|
4703 4904 | /// When input is empty we write CBOR equivalent of {}
|
4704 4905 | /// Test ID: optional_input
|
4705 4906 | #[::tokio::test]
|
4706 4907 | #[::tracing_test::traced_test]
|
4707 4908 | async fn optional_input_request() {
|
4708 4909 | #[allow(unused_mut)]
|
4709 - | let mut http_request = http::Request::builder()
|
4910 + | let mut http_request = ::http_1x::Request::builder()
|
4710 4911 | .uri("/service/RpcV2Protocol/operation/OptionalInputOutput")
|
4711 4912 | .method("POST")
|
4712 4913 | .header("Accept", "application/cbor")
|
4713 4914 | .header("Content-Type", "application/cbor")
|
4714 4915 | .header("smithy-protocol", "rpc-v2-cbor")
|
4715 - | .body(::aws_smithy_http_server::body::Body::from(
|
4716 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4916 + | .body(::aws_smithy_http_server::body::boxed(
|
4917 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4918 + | &::aws_smithy_protocol_test::decode_body_data(
|
4717 4919 | "v/8=".as_bytes(),
|
4718 4920 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4921 + | ),
|
4719 4922 | )),
|
4720 4923 | ))
|
4721 4924 | .unwrap();
|
4722 4925 | #[allow(unused_mut)]
|
4723 4926 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4724 4927 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4725 - | let service =
|
4726 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4928 + | let service = crate::service::RpcV2Protocol::builder::<
|
4929 + | ::aws_smithy_http_server::body::BoxBody,
|
4930 + | _,
|
4931 + | _,
|
4932 + | _,
|
4933 + | >(config)
|
4727 4934 | .optional_input_output(move |input: crate::input::OptionalInputOutputInput| {
|
4728 4935 | let sender = sender.clone();
|
4729 4936 | async move {
|
4730 4937 | let result = {
|
4731 4938 | let expected = crate::input::OptionalInputOutputInput {
|
4732 4939 | value: ::std::option::Option::None,
|
4733 4940 | };
|
4734 4941 | ::pretty_assertions::assert_eq!(input, expected);
|
4735 4942 | let output = crate::output::OptionalInputOutputOutput {
|
4736 4943 | value: ::std::option::Option::None,
|
4737 4944 | };
|
4738 4945 | output
|
4739 4946 | };
|
4740 4947 | sender.send(()).await.expect("receiver dropped early");
|
4741 4948 | result
|
4742 4949 | }
|
4743 4950 | })
|
4744 4951 | .build_unchecked();
|
4745 4952 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4746 4953 | .await
|
4747 4954 | .expect("unable to make an HTTP request");
|
4748 4955 | assert!(
|
4749 4956 | receiver.recv().await.is_some(),
|
4750 4957 | "we expected operation handler to be invoked but it was not entered"
|
4751 4958 | );
|
4752 4959 | }
|
4753 4960 |
|
4754 4961 | /// When output is empty we write CBOR equivalent of {}
|
4755 4962 | /// Test ID: optional_output
|
4756 4963 | #[::tokio::test]
|
4757 4964 | #[::tracing_test::traced_test]
|
4758 4965 | async fn optional_output_response() {
|
4759 4966 | let output = crate::output::OptionalInputOutputOutput {
|
4760 4967 | value: ::std::option::Option::None,
|
4761 4968 | };
|
4762 4969 | use ::aws_smithy_http_server::response::IntoResponse;
|
4763 4970 | let http_response = output.into_response();
|
4764 4971 | ::pretty_assertions::assert_eq!(
|
4765 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4972 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4766 4973 | http_response.status()
|
4767 4974 | );
|
4768 4975 | let expected_headers = [
|
4769 4976 | ("Content-Type", "application/cbor"),
|
4770 4977 | ("smithy-protocol", "rpc-v2-cbor"),
|
4771 4978 | ];
|
4772 4979 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4773 4980 | http_response.headers(),
|
4774 4981 | expected_headers,
|
4775 4982 | ));
|
4776 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4983 + | use ::http_body_util::BodyExt;
|
4984 + | let body = http_response
|
4985 + | .into_body()
|
4986 + | .collect()
|
4777 4987 | .await
|
4778 - | .expect("unable to extract body to bytes");
|
4988 + | .expect("unable to collect body")
|
4989 + | .to_bytes();
|
4779 4990 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4780 4991 | &body,
|
4781 4992 | "v/8=",
|
4782 4993 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4783 4994 | ));
|
4784 4995 | }
|
4785 4996 | }
|
4786 4997 |
|
4787 4998 | ::pin_project_lite::pin_project! {
|
4788 4999 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4789 5000 | /// [`EmptyInputOutputInput`](crate::input::EmptyInputOutputInput) using modelled bindings.
|
4790 5001 | pub struct EmptyInputOutputInputFuture {
|
4791 5002 | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyInputOutputInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4792 5003 | }
|
4793 5004 | }
|
4794 5005 |
|
4795 5006 | impl std::future::Future for EmptyInputOutputInputFuture {
|
4796 5007 | type Output = Result<
|
4797 5008 | crate::input::EmptyInputOutputInput,
|
4798 5009 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
4799 5010 | >;
|
4800 5011 |
|
4801 5012 | fn poll(
|
4802 5013 | self: std::pin::Pin<&mut Self>,
|
4803 5014 | cx: &mut std::task::Context<'_>,
|
4804 5015 | ) -> std::task::Poll<Self::Output> {
|
4805 5016 | let this = self.project();
|
4806 5017 | this.inner.as_mut().poll(cx)
|
4807 5018 | }
|
4808 5019 | }
|
4809 5020 |
|
4810 5021 | impl<B>
|
4811 5022 | ::aws_smithy_http_server::request::FromRequest<
|
4812 5023 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4813 5024 | B,
|
4814 5025 | > for crate::input::EmptyInputOutputInput
|
4815 5026 | where
|
4816 5027 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
4817 5028 | B: 'static,
|
4818 5029 |
|
4819 5030 | B::Data: Send,
|
4820 5031 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
4821 5032 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
4822 5033 | {
|
4823 5034 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
4824 5035 | type Future = EmptyInputOutputInputFuture;
|
4825 5036 |
|
4826 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
5037 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
4827 5038 | let fut = async move {
|
4828 5039 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
4829 5040 | request.headers(),
|
4830 5041 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
4831 5042 | ) {
|
4832 5043 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
4833 5044 | }
|
4834 5045 | crate::protocol_serde::shape_empty_input_output::de_empty_input_output_http_request(
|
4835 5046 | request,
|
4836 5047 | )
|
4837 5048 | .await
|
4838 5049 | };
|
4839 5050 | use ::futures_util::future::TryFutureExt;
|
4840 5051 | let fut = fut.map_err(
|
4841 5052 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
4842 5053 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4843 5054 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
4844 5055 | e,
|
4845 5056 | )
|
4846 5057 | },
|
4847 5058 | );
|
4848 5059 | EmptyInputOutputInputFuture {
|
4849 5060 | inner: Box::pin(fut),
|
4850 5061 | }
|
4851 5062 | }
|
4852 5063 | }
|
4853 5064 | impl
|
4854 5065 | ::aws_smithy_http_server::response::IntoResponse<
|
4855 5066 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4856 5067 | > for crate::output::EmptyInputOutputOutput
|
4857 5068 | {
|
4858 5069 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
4859 5070 | match crate::protocol_serde::shape_empty_input_output::ser_empty_input_output_http_response(
|
4860 5071 | self,
|
4861 5072 | ) {
|
4862 5073 | Ok(response) => response,
|
4863 5074 | Err(e) => {
|
4864 5075 | ::tracing::error!(error = %e, "failed to serialize response");
|
4865 5076 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4866 5077 | }
|
4867 5078 | }
|
4868 5079 | }
|
4869 5080 | }
|
4870 5081 |
|
4871 5082 | #[allow(unreachable_code, unused_variables)]
|
4872 5083 | #[cfg(test)]
|
4873 5084 | mod empty_input_output_test {
|
4874 5085 |
|
4875 5086 | /// When Input structure is empty we write CBOR equivalent of {}
|
4876 5087 | /// Test ID: empty_input
|
4877 5088 | #[::tokio::test]
|
4878 5089 | #[::tracing_test::traced_test]
|
4879 5090 | async fn empty_input_request() {
|
4880 5091 | #[allow(unused_mut)]
|
4881 - | let mut http_request = http::Request::builder()
|
5092 + | let mut http_request = ::http_1x::Request::builder()
|
4882 5093 | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
4883 5094 | .method("POST")
|
4884 5095 | .header("Accept", "application/cbor")
|
4885 5096 | .header("Content-Type", "application/cbor")
|
4886 5097 | .header("smithy-protocol", "rpc-v2-cbor")
|
4887 - | .body(::aws_smithy_http_server::body::Body::from(
|
4888 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5098 + | .body(::aws_smithy_http_server::body::boxed(
|
5099 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5100 + | &::aws_smithy_protocol_test::decode_body_data(
|
4889 5101 | "v/8=".as_bytes(),
|
4890 5102 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5103 + | ),
|
4891 5104 | )),
|
4892 5105 | ))
|
4893 5106 | .unwrap();
|
4894 5107 | #[allow(unused_mut)]
|
4895 5108 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4896 5109 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4897 - | let service =
|
4898 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
5110 + | let service = crate::service::RpcV2Protocol::builder::<
|
5111 + | ::aws_smithy_http_server::body::BoxBody,
|
5112 + | _,
|
5113 + | _,
|
5114 + | _,
|
5115 + | >(config)
|
4899 5116 | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
4900 5117 | let sender = sender.clone();
|
4901 5118 | async move {
|
4902 5119 | let result = {
|
4903 5120 | let expected = crate::input::EmptyInputOutputInput {};
|
4904 5121 | ::pretty_assertions::assert_eq!(input, expected);
|
4905 5122 | let output = crate::output::EmptyInputOutputOutput {};
|
4906 5123 | output
|
4907 5124 | };
|
4908 5125 | sender.send(()).await.expect("receiver dropped early");
|
4909 5126 | result
|
4910 5127 | }
|
4911 5128 | })
|
4912 5129 | .build_unchecked();
|
4913 5130 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4914 5131 | .await
|
4915 5132 | .expect("unable to make an HTTP request");
|
4916 5133 | assert!(
|
4917 5134 | receiver.recv().await.is_some(),
|
4918 5135 | "we expected operation handler to be invoked but it was not entered"
|
4919 5136 | );
|
4920 5137 | }
|
4921 5138 |
|
4922 5139 | /// When Input structure is empty the server should accept an empty body
|
4923 5140 | /// Test ID: empty_input_no_body
|
4924 5141 | #[::tokio::test]
|
4925 5142 | #[::tracing_test::traced_test]
|
4926 5143 | async fn empty_input_no_body_request() {
|
4927 5144 | #[allow(unused_mut)]
|
4928 - | let mut http_request = http::Request::builder()
|
5145 + | let mut http_request = ::http_1x::Request::builder()
|
4929 5146 | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
4930 5147 | .method("POST")
|
4931 5148 | .header("Accept", "application/cbor")
|
4932 5149 | .header("Content-Type", "application/cbor")
|
4933 5150 | .header("smithy-protocol", "rpc-v2-cbor")
|
4934 - | .body(::aws_smithy_http_server::body::Body::from(
|
4935 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5151 + | .body(::aws_smithy_http_server::body::boxed(
|
5152 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5153 + | &::aws_smithy_protocol_test::decode_body_data(
|
4936 5154 | "".as_bytes(),
|
4937 5155 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5156 + | ),
|
4938 5157 | )),
|
4939 5158 | ))
|
4940 5159 | .unwrap();
|
4941 5160 | #[allow(unused_mut)]
|
4942 5161 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4943 5162 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4944 - | let service =
|
4945 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
5163 + | let service = crate::service::RpcV2Protocol::builder::<
|
5164 + | ::aws_smithy_http_server::body::BoxBody,
|
5165 + | _,
|
5166 + | _,
|
5167 + | _,
|
5168 + | >(config)
|
4946 5169 | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
4947 5170 | let sender = sender.clone();
|
4948 5171 | async move {
|
4949 5172 | let result = {
|
4950 5173 | let expected = crate::input::EmptyInputOutputInput {};
|
4951 5174 | ::pretty_assertions::assert_eq!(input, expected);
|
4952 5175 | let output = crate::output::EmptyInputOutputOutput {};
|
4953 5176 | output
|
4954 5177 | };
|
4955 5178 | sender.send(()).await.expect("receiver dropped early");
|
4956 5179 | result
|
4957 5180 | }
|
4958 5181 | })
|
4959 5182 | .build_unchecked();
|
4960 5183 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4961 5184 | .await
|
4962 5185 | .expect("unable to make an HTTP request");
|
4963 5186 | assert!(
|
4964 5187 | receiver.recv().await.is_some(),
|
4965 5188 | "we expected operation handler to be invoked but it was not entered"
|
4966 5189 | );
|
4967 5190 | }
|
4968 5191 |
|
4969 5192 | /// When input structure, is empty the server should accept an empty body
|
4970 5193 | /// even if the Accept header is set.
|
4971 5194 | /// Test ID: empty_input_no_body_has_accept
|
4972 5195 | #[::tokio::test]
|
4973 5196 | #[::tracing_test::traced_test]
|
4974 5197 | async fn empty_input_no_body_has_accept_request() {
|
4975 5198 | #[allow(unused_mut)]
|
4976 - | let mut http_request = http::Request::builder()
|
5199 + | let mut http_request = ::http_1x::Request::builder()
|
4977 5200 | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
4978 5201 | .method("POST")
|
4979 5202 | .header("Accept", "application/cbor")
|
4980 5203 | .header("Content-Type", "application/cbor")
|
4981 5204 | .header("smithy-protocol", "rpc-v2-cbor")
|
4982 - | .body(::aws_smithy_http_server::body::Body::from(
|
4983 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5205 + | .body(::aws_smithy_http_server::body::boxed(
|
5206 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5207 + | &::aws_smithy_protocol_test::decode_body_data(
|
4984 5208 | "".as_bytes(),
|
4985 5209 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5210 + | ),
|
4986 5211 | )),
|
4987 5212 | ))
|
4988 5213 | .unwrap();
|
4989 5214 | #[allow(unused_mut)]
|
4990 5215 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4991 5216 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4992 - | let service =
|
4993 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
5217 + | let service = crate::service::RpcV2Protocol::builder::<
|
5218 + | ::aws_smithy_http_server::body::BoxBody,
|
5219 + | _,
|
5220 + | _,
|
5221 + | _,
|
5222 + | >(config)
|
4994 5223 | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
4995 5224 | let sender = sender.clone();
|
4996 5225 | async move {
|
4997 5226 | let result = {
|
4998 5227 | let expected = crate::input::EmptyInputOutputInput {};
|
4999 5228 | ::pretty_assertions::assert_eq!(input, expected);
|
5000 5229 | let output = crate::output::EmptyInputOutputOutput {};
|
5001 5230 | output
|
5002 5231 | };
|
5003 5232 | sender.send(()).await.expect("receiver dropped early");
|
5004 5233 | result
|
5005 5234 | }
|
5006 5235 | })
|
5007 5236 | .build_unchecked();
|
5008 5237 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5009 5238 | .await
|
5010 5239 | .expect("unable to make an HTTP request");
|
5011 5240 | assert!(
|
5012 5241 | receiver.recv().await.is_some(),
|
5013 5242 | "we expected operation handler to be invoked but it was not entered"
|
5014 5243 | );
|
5015 5244 | }
|
5016 5245 |
|
5017 5246 | /// When output structure is empty we write CBOR equivalent of {}
|
5018 5247 | /// Test ID: empty_output
|
5019 5248 | #[::tokio::test]
|
5020 5249 | #[::tracing_test::traced_test]
|
5021 5250 | async fn empty_output_response() {
|
5022 5251 | let output = crate::output::EmptyInputOutputOutput {};
|
5023 5252 | use ::aws_smithy_http_server::response::IntoResponse;
|
5024 5253 | let http_response = output.into_response();
|
5025 5254 | ::pretty_assertions::assert_eq!(
|
5026 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
5255 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
5027 5256 | http_response.status()
|
5028 5257 | );
|
5029 5258 | let expected_headers = [
|
5030 5259 | ("Content-Type", "application/cbor"),
|
5031 5260 | ("smithy-protocol", "rpc-v2-cbor"),
|
5032 5261 | ];
|
5033 5262 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5034 5263 | http_response.headers(),
|
5035 5264 | expected_headers,
|
5036 5265 | ));
|
5037 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5266 + | use ::http_body_util::BodyExt;
|
5267 + | let body = http_response
|
5268 + | .into_body()
|
5269 + | .collect()
|
5038 5270 | .await
|
5039 - | .expect("unable to extract body to bytes");
|
5271 + | .expect("unable to collect body")
|
5272 + | .to_bytes();
|
5040 5273 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
5041 5274 | &body,
|
5042 5275 | "v/8=",
|
5043 5276 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5044 5277 | ));
|
5045 5278 | }
|
5046 5279 | }
|
5047 5280 |
|
5048 5281 | ::pin_project_lite::pin_project! {
|
5049 5282 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5050 5283 | /// [`NoInputOutputInput`](crate::input::NoInputOutputInput) using modelled bindings.
|
5051 5284 | pub struct NoInputOutputInputFuture {
|
5052 5285 | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::NoInputOutputInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
5053 5286 | }
|
5054 5287 | }
|
5055 5288 |
|
5056 5289 | impl std::future::Future for NoInputOutputInputFuture {
|
5057 5290 | type Output = Result<
|
5058 5291 | crate::input::NoInputOutputInput,
|
5059 5292 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
5060 5293 | >;
|
5061 5294 |
|
5062 5295 | fn poll(
|
5063 5296 | self: std::pin::Pin<&mut Self>,
|
5064 5297 | cx: &mut std::task::Context<'_>,
|
5065 5298 | ) -> std::task::Poll<Self::Output> {
|
5066 5299 | let this = self.project();
|
5067 5300 | this.inner.as_mut().poll(cx)
|
5068 5301 | }
|
5069 5302 | }
|
5070 5303 |
|
5071 5304 | impl<B>
|
5072 5305 | ::aws_smithy_http_server::request::FromRequest<
|
5073 5306 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
5074 5307 | B,
|
5075 5308 | > for crate::input::NoInputOutputInput
|
5076 5309 | where
|
5077 5310 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
5078 5311 | B: 'static,
|
5079 5312 |
|
5080 5313 | B::Data: Send,
|
5081 5314 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
5082 5315 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
5083 5316 | {
|
5084 5317 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
5085 5318 | type Future = NoInputOutputInputFuture;
|
5086 5319 |
|
5087 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
5320 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
5088 5321 | let fut = async move {
|
5089 5322 | crate::protocol_serde::shape_no_input_output::de_no_input_output_http_request(request)
|
5090 5323 | .await
|
5091 5324 | };
|
5092 5325 | use ::futures_util::future::TryFutureExt;
|
5093 5326 | let fut = fut.map_err(
|
5094 5327 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
5095 5328 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5096 5329 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
5097 5330 | e,
|
5098 5331 | )
|
5099 5332 | },
|
5100 5333 | );
|
5101 5334 | NoInputOutputInputFuture {
|
5102 5335 | inner: Box::pin(fut),
|
5103 5336 | }
|
5104 5337 | }
|
5105 5338 | }
|
5106 5339 | impl
|
5107 5340 | ::aws_smithy_http_server::response::IntoResponse<
|
5108 5341 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
5109 5342 | > for crate::output::NoInputOutputOutput
|
5110 5343 | {
|
5111 5344 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
5112 5345 | match crate::protocol_serde::shape_no_input_output::ser_no_input_output_http_response(self)
|
5113 5346 | {
|
5114 5347 | Ok(response) => response,
|
5115 5348 | Err(e) => {
|
5116 5349 | ::tracing::error!(error = %e, "failed to serialize response");
|
5117 5350 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
5118 5351 | }
|
5119 5352 | }
|
5120 5353 | }
|
5121 5354 | }
|
5122 5355 |
|
5123 5356 | #[allow(unreachable_code, unused_variables)]
|
5124 5357 | #[cfg(test)]
|
5125 5358 | mod no_input_output_test {
|
5126 5359 |
|
5127 5360 | /// Body is empty and no Content-Type header if no input
|
5128 5361 | /// Test ID: no_input
|
5129 5362 | #[::tokio::test]
|
5130 5363 | #[::tracing_test::traced_test]
|
5131 5364 | async fn no_input_request() {
|
5132 5365 | #[allow(unused_mut)]
|
5133 - | let mut http_request = http::Request::builder()
|
5366 + | let mut http_request = ::http_1x::Request::builder()
|
5134 5367 | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
5135 5368 | .method("POST")
|
5136 5369 | .header("Accept", "application/cbor")
|
5137 5370 | .header("smithy-protocol", "rpc-v2-cbor")
|
5138 - | .body(::aws_smithy_http_server::body::Body::from(
|
5139 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5371 + | .body(::aws_smithy_http_server::body::boxed(
|
5372 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5373 + | &::aws_smithy_protocol_test::decode_body_data(
|
5140 5374 | "".as_bytes(),
|
5141 5375 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5376 + | ),
|
5142 5377 | )),
|
5143 5378 | ))
|
5144 5379 | .unwrap();
|
5145 5380 | #[allow(unused_mut)]
|
5146 5381 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5147 5382 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5148 - | let service =
|
5149 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
5383 + | let service = crate::service::RpcV2Protocol::builder::<
|
5384 + | ::aws_smithy_http_server::body::BoxBody,
|
5385 + | _,
|
5386 + | _,
|
5387 + | _,
|
5388 + | >(config)
|
5150 5389 | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
5151 5390 | let sender = sender.clone();
|
5152 5391 | async move {
|
5153 5392 | let result = {
|
5154 5393 | let expected = crate::input::NoInputOutputInput {};
|
5155 5394 | ::pretty_assertions::assert_eq!(input, expected);
|
5156 5395 | let output = crate::output::NoInputOutputOutput {};
|
5157 5396 | output
|
5158 5397 | };
|
5159 5398 | sender.send(()).await.expect("receiver dropped early");
|
5160 5399 | result
|
5161 5400 | }
|
5162 5401 | })
|
5163 5402 | .build_unchecked();
|
5164 5403 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5165 5404 | .await
|
5166 5405 | .expect("unable to make an HTTP request");
|
5167 5406 | assert!(
|
5168 5407 | receiver.recv().await.is_some(),
|
5169 5408 | "we expected operation handler to be invoked but it was not entered"
|
5170 5409 | );
|
5171 5410 | }
|
5172 5411 |
|
5173 5412 | /// Servers should accept CBOR empty struct if no input.
|
5174 5413 | /// Test ID: NoInputServerAllowsEmptyCbor
|
5175 5414 | #[::tokio::test]
|
5176 5415 | #[::tracing_test::traced_test]
|
5177 5416 | async fn no_input_server_allows_empty_cbor_request() {
|
5178 5417 | #[allow(unused_mut)]
|
5179 - | let mut http_request = http::Request::builder()
|
5418 + | let mut http_request = ::http_1x::Request::builder()
|
5180 5419 | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
5181 5420 | .method("POST")
|
5182 5421 | .header("Accept", "application/cbor")
|
5183 5422 | .header("Content-Type", "application/cbor")
|
5184 5423 | .header("smithy-protocol", "rpc-v2-cbor")
|
5185 - | .body(::aws_smithy_http_server::body::Body::from(
|
5186 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5424 + | .body(::aws_smithy_http_server::body::boxed(
|
5425 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5426 + | &::aws_smithy_protocol_test::decode_body_data(
|
5187 5427 | "v/8=".as_bytes(),
|
5188 5428 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5429 + | ),
|
5189 5430 | )),
|
5190 5431 | ))
|
5191 5432 | .unwrap();
|
5192 5433 | #[allow(unused_mut)]
|
5193 5434 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5194 5435 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5195 - | let service =
|
5196 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
5436 + | let service = crate::service::RpcV2Protocol::builder::<
|
5437 + | ::aws_smithy_http_server::body::BoxBody,
|
5438 + | _,
|
5439 + | _,
|
5440 + | _,
|
5441 + | >(config)
|
5197 5442 | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
5198 5443 | let sender = sender.clone();
|
5199 5444 | async move {
|
5200 5445 | let result = {
|
5201 5446 | let expected = crate::input::NoInputOutputInput {};
|
5202 5447 | ::pretty_assertions::assert_eq!(input, expected);
|
5203 5448 | let output = crate::output::NoInputOutputOutput {};
|
5204 5449 | output
|
5205 5450 | };
|
5206 5451 | sender.send(()).await.expect("receiver dropped early");
|
5207 5452 | result
|
5208 5453 | }
|
5209 5454 | })
|
5210 5455 | .build_unchecked();
|
5211 5456 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5212 5457 | .await
|
5213 5458 | .expect("unable to make an HTTP request");
|
5214 5459 | assert!(
|
5215 5460 | receiver.recv().await.is_some(),
|
5216 5461 | "we expected operation handler to be invoked but it was not entered"
|
5217 5462 | );
|
5218 5463 | }
|
5219 5464 |
|
5220 5465 | /// Servers should accept an empty body if there is no input. Additionally,
|
5221 5466 | /// they should not raise an error if the `Accept` header is set.
|
5222 5467 | /// Test ID: NoInputServerAllowsEmptyBody
|
5223 5468 | #[::tokio::test]
|
5224 5469 | #[::tracing_test::traced_test]
|
5225 5470 | async fn no_input_server_allows_empty_body_request() {
|
5226 5471 | #[allow(unused_mut)]
|
5227 - | let mut http_request = http::Request::builder()
|
5472 + | let mut http_request = ::http_1x::Request::builder()
|
5228 5473 | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
5229 5474 | .method("POST")
|
5230 5475 | .header("Accept", "application/cbor")
|
5231 5476 | .header("Content-Type", "application/cbor")
|
5232 5477 | .header("smithy-protocol", "rpc-v2-cbor")
|
5233 - | .body(::aws_smithy_http_server::body::Body::from(
|
5234 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5478 + | .body(::aws_smithy_http_server::body::boxed(
|
5479 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5480 + | &::aws_smithy_protocol_test::decode_body_data(
|
5235 5481 | "".as_bytes(),
|
5236 5482 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5483 + | ),
|
5237 5484 | )),
|
5238 5485 | ))
|
5239 5486 | .unwrap();
|
5240 5487 | #[allow(unused_mut)]
|
5241 5488 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5242 5489 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5243 - | let service =
|
5244 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
5490 + | let service = crate::service::RpcV2Protocol::builder::<
|
5491 + | ::aws_smithy_http_server::body::BoxBody,
|
5492 + | _,
|
5493 + | _,
|
5494 + | _,
|
5495 + | >(config)
|
5245 5496 | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
5246 5497 | let sender = sender.clone();
|
5247 5498 | async move {
|
5248 5499 | let result = {
|
5249 5500 | let expected = crate::input::NoInputOutputInput {};
|
5250 5501 | ::pretty_assertions::assert_eq!(input, expected);
|
5251 5502 | let output = crate::output::NoInputOutputOutput {};
|
5252 5503 | output
|
5253 5504 | };
|
5254 5505 | sender.send(()).await.expect("receiver dropped early");
|
5255 5506 | result
|
5256 5507 | }
|
5257 5508 | })
|
5258 5509 | .build_unchecked();
|
5259 5510 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5260 5511 | .await
|
5261 5512 | .expect("unable to make an HTTP request");
|
5262 5513 | assert!(
|
5263 5514 | receiver.recv().await.is_some(),
|
5264 5515 | "we expected operation handler to be invoked but it was not entered"
|
5265 5516 | );
|
5266 5517 | }
|
5267 5518 |
|
5268 5519 | /// A `Content-Type` header should not be set if the response body is empty.
|
5269 5520 | /// Test ID: no_output
|
5270 5521 | #[::tokio::test]
|
5271 5522 | #[::tracing_test::traced_test]
|
5272 5523 | async fn no_output_response() {
|
5273 5524 | let output = crate::output::NoInputOutputOutput {};
|
5274 5525 | use ::aws_smithy_http_server::response::IntoResponse;
|
5275 5526 | let http_response = output.into_response();
|
5276 5527 | ::pretty_assertions::assert_eq!(
|
5277 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
5528 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
5278 5529 | http_response.status()
|
5279 5530 | );
|
5280 5531 | let expected_headers = [("smithy-protocol", "rpc-v2-cbor")];
|
5281 5532 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5282 5533 | http_response.headers(),
|
5283 5534 | expected_headers,
|
5284 5535 | ));
|
5285 5536 | let forbidden_headers = &["Content-Type"];
|
5286 5537 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::forbid_headers(
|
5287 5538 | http_response.headers(),
|
5288 5539 | forbidden_headers,
|
5289 5540 | ));
|
5290 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5541 + | use ::http_body_util::BodyExt;
|
5542 + | let body = http_response
|
5543 + | .into_body()
|
5544 + | .collect()
|
5291 5545 | .await
|
5292 - | .expect("unable to extract body to bytes");
|
5546 + | .expect("unable to collect body")
|
5547 + | .to_bytes();
|
5293 5548 | // No body.
|
5294 5549 | ::pretty_assertions::assert_eq!(&body, &bytes::Bytes::new());
|
5295 5550 | }
|
5296 5551 | }
|