614 634 | )
|
615 635 | ,
|
616 636 | }
|
617 637 | )
|
618 638 | ,
|
619 639 | }
|
620 640 | ;
|
621 641 | use ::aws_smithy_http_server::response::IntoResponse;
|
622 642 | let http_response = output.into_response();
|
623 643 | ::pretty_assertions::assert_eq!(
|
624 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
644 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
625 645 | http_response.status()
|
626 646 | );
|
627 647 | let expected_headers = [
|
628 648 | ("Content-Type", "application/cbor"),
|
629 649 | ("smithy-protocol", "rpc-v2-cbor"),
|
630 650 | ];
|
631 651 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
632 652 | http_response.headers(),
|
633 653 | expected_headers,
|
634 654 | ));
|
635 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
655 + | use ::http_body_util::BodyExt;
|
656 + | let body = http_response
|
657 + | .into_body()
|
658 + | .collect()
|
636 659 | .await
|
637 - | .expect("unable to extract body to bytes");
|
660 + | .expect("unable to collect body")
|
661 + | .to_bytes();
|
638 662 | ::aws_smithy_protocol_test::assert_ok(
|
639 663 | ::aws_smithy_protocol_test::validate_body(&body, "v2ZuZXN0ZWS/Y2Zvb2RGb28xZ3ZhcmlhbnS/Z2Nob2ljZTFrT3V0ZXJDaG9pY2X/Zm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmd2YXJpYW50v2djaG9pY2Uyv2Nmb29kRm9vM2ZuZXN0ZWS/Y2JhcmRCYXIzb3JlY3Vyc2l2ZU1lbWJlcr9jZm9vZEZvbzRndmFyaWFudL9nY2hvaWNlMWtJbm5lckNob2ljZf//////Zm5lc3RlZL9jYmFyZEJhcjL//////w==", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
640 664 | );
|
641 665 | }
|
642 666 | }
|
643 667 |
|
644 668 | ::pin_project_lite::pin_project! {
|
645 669 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
646 670 | /// [`SingleMemberStructOperationInput`](crate::input::SingleMemberStructOperationInput) using modelled bindings.
|
647 671 | pub struct SingleMemberStructOperationInputFuture {
|
648 672 | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SingleMemberStructOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
649 673 | }
|
650 674 | }
|
651 675 |
|
652 676 | impl std::future::Future for SingleMemberStructOperationInputFuture {
|
653 677 | type Output = Result<
|
654 678 | crate::input::SingleMemberStructOperationInput,
|
655 679 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
656 680 | >;
|
657 681 |
|
658 682 | fn poll(
|
659 683 | self: std::pin::Pin<&mut Self>,
|
660 684 | cx: &mut std::task::Context<'_>,
|
661 685 | ) -> std::task::Poll<Self::Output> {
|
662 686 | let this = self.project();
|
663 687 | this.inner.as_mut().poll(cx)
|
664 688 | }
|
665 689 | }
|
666 690 |
|
667 691 | impl<B>
|
668 692 | ::aws_smithy_http_server::request::FromRequest<
|
669 693 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
670 694 | B,
|
671 695 | > for crate::input::SingleMemberStructOperationInput
|
672 696 | where
|
673 697 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
674 698 | B: 'static,
|
675 699 |
|
676 700 | B::Data: Send,
|
677 701 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
678 702 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
679 703 | {
|
680 704 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
681 705 | type Future = SingleMemberStructOperationInputFuture;
|
682 706 |
|
683 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
707 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
684 708 | let fut = async move {
|
685 709 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
686 710 | request.headers(),
|
687 711 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
688 712 | ) {
|
689 713 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
690 714 | }
|
691 715 | crate::protocol_serde::shape_single_member_struct_operation::de_single_member_struct_operation_http_request(request)
|
692 716 | .await
|
693 717 | };
|
694 718 | use ::futures_util::future::TryFutureExt;
|
695 719 | let fut = fut.map_err(
|
696 720 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
697 721 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
698 722 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
699 723 | e,
|
700 724 | )
|
701 725 | },
|
702 726 | );
|
703 727 | SingleMemberStructOperationInputFuture {
|
704 728 | inner: Box::pin(fut),
|
705 729 | }
|
706 730 | }
|
707 731 | }
|
708 732 | impl
|
709 733 | ::aws_smithy_http_server::response::IntoResponse<
|
710 734 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
711 735 | > for crate::output::SingleMemberStructOperationOutput
|
712 736 | {
|
713 737 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
714 738 | match crate::protocol_serde::shape_single_member_struct_operation::ser_single_member_struct_operation_http_response(self) {
|
715 739 | Ok(response) => response,
|
716 740 | Err(e) => {
|
717 741 | ::tracing::error!(error = %e, "failed to serialize response");
|
718 742 | ::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))
|
719 743 | }
|
720 744 | }
|
721 745 | }
|
722 746 | }
|
723 747 |
|
724 748 | #[allow(unreachable_code, unused_variables)]
|
725 749 | #[cfg(test)]
|
726 750 | mod single_member_struct_operation_test {
|
727 751 |
|
728 752 | /// When additional tokens are found past where we expect the end of the body,
|
729 753 | /// the request should be rejected with a serialization exception.
|
730 754 | /// Test ID: AdditionalTokensSingleMemberStruct
|
731 755 | #[::tokio::test]
|
732 756 | #[::tracing_test::traced_test]
|
733 757 | async fn additional_tokens_single_member_struct_malformed_request() {
|
734 758 | {
|
735 759 | #[allow(unused_mut)]
|
736 - | let mut http_request = http::Request::builder()
|
760 + | let mut http_request = ::http_1x::Request::builder()
|
737 761 | .uri("/service/RpcV2CborService/operation/SingleMemberStructOperation")
|
738 762 | .method("POST")
|
739 763 | .header("smithy-protocol", "rpc-v2-cbor")
|
740 764 | .header("Accept", "application/cbor")
|
741 765 | .header("Content-Type", "application/cbor")
|
742 - | .body(::aws_smithy_http_server::body::Body::from(
|
743 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
766 + | .body(::aws_smithy_http_server::body::boxed(
|
767 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
768 + | &::aws_smithy_protocol_test::decode_body_data(
|
744 769 | "v/+//w==".as_bytes(),
|
745 770 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
771 + | ),
|
746 772 | )),
|
747 773 | ))
|
748 774 | .unwrap();
|
749 775 | #[allow(unused_mut)]
|
750 776 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
751 777 | let config = crate::service::RpcV2CborServiceConfig::builder().build();
|
752 - | let service = crate::service::RpcV2CborService::builder::<::hyper::body::Body, _, _, _>(config)
|
778 + | let service = crate::service::RpcV2CborService::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
753 779 | .single_member_struct_operation(move |input: crate::input::SingleMemberStructOperationInput| {
|
754 780 | let sender = sender.clone();
|
755 781 | async move {
|
756 782 | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as crate::output::SingleMemberStructOperationOutput };
|
757 783 | sender.send(()).await.expect("receiver dropped early");
|
758 784 | result
|
759 785 | }
|
760 786 | })
|
761 787 | .build_unchecked();
|
762 788 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
763 789 | .await
|
764 790 | .expect("unable to make an HTTP request");
|
765 791 | ::pretty_assertions::assert_eq!(
|
766 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
792 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
767 793 | http_response.status()
|
768 794 | );
|
769 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
795 + | use ::http_body_util::BodyExt;
|
796 + | let body = http_response
|
797 + | .into_body()
|
798 + | .collect()
|
770 799 | .await
|
771 - | .expect("unable to extract body to bytes");
|
800 + | .expect("unable to collect body")
|
801 + | .to_bytes();
|
772 802 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
773 803 | &body,
|
774 804 | "oA==",
|
775 805 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
776 806 | ));
|
777 807 | }
|
778 808 | }
|
779 809 | }
|
780 810 |
|
781 811 | ::pin_project_lite::pin_project! {
|
782 812 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
783 813 | /// [`EmptyStructOperationInput`](crate::input::EmptyStructOperationInput) using modelled bindings.
|
784 814 | pub struct EmptyStructOperationInputFuture {
|
785 815 | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyStructOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
786 816 | }
|
787 817 | }
|
788 818 |
|
789 819 | impl std::future::Future for EmptyStructOperationInputFuture {
|
790 820 | type Output = Result<
|
791 821 | crate::input::EmptyStructOperationInput,
|
792 822 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
793 823 | >;
|
794 824 |
|
795 825 | fn poll(
|
796 826 | self: std::pin::Pin<&mut Self>,
|
797 827 | cx: &mut std::task::Context<'_>,
|
798 828 | ) -> std::task::Poll<Self::Output> {
|
799 829 | let this = self.project();
|
800 830 | this.inner.as_mut().poll(cx)
|
801 831 | }
|
802 832 | }
|
803 833 |
|
804 834 | impl<B>
|
805 835 | ::aws_smithy_http_server::request::FromRequest<
|
806 836 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
807 837 | B,
|
808 838 | > for crate::input::EmptyStructOperationInput
|
809 839 | where
|
810 840 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
811 841 | B: 'static,
|
812 842 |
|
813 843 | B::Data: Send,
|
814 844 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
815 845 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
816 846 | {
|
817 847 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
818 848 | type Future = EmptyStructOperationInputFuture;
|
819 849 |
|
820 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
850 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
821 851 | let fut = async move {
|
822 852 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
823 853 | request.headers(),
|
824 854 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
825 855 | ) {
|
826 856 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
827 857 | }
|
828 858 | crate::protocol_serde::shape_empty_struct_operation::de_empty_struct_operation_http_request(request)
|
829 859 | .await
|
830 860 | };
|
831 861 | use ::futures_util::future::TryFutureExt;
|
832 862 | let fut = fut.map_err(
|
833 863 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
834 864 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
835 865 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
836 866 | e,
|
837 867 | )
|
838 868 | },
|
839 869 | );
|
840 870 | EmptyStructOperationInputFuture {
|
841 871 | inner: Box::pin(fut),
|
842 872 | }
|
843 873 | }
|
844 874 | }
|
845 875 | impl
|
846 876 | ::aws_smithy_http_server::response::IntoResponse<
|
847 877 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
848 878 | > for crate::output::EmptyStructOperationOutput
|
849 879 | {
|
850 880 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
851 881 | match crate::protocol_serde::shape_empty_struct_operation::ser_empty_struct_operation_http_response(self) {
|
852 882 | Ok(response) => response,
|
853 883 | Err(e) => {
|
854 884 | ::tracing::error!(error = %e, "failed to serialize response");
|
855 885 | ::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))
|
856 886 | }
|
857 887 | }
|
858 888 | }
|
859 889 | }
|
860 890 |
|
861 891 | #[allow(unreachable_code, unused_variables)]
|
862 892 | #[cfg(test)]
|
863 893 | mod empty_struct_operation_test {
|
864 894 |
|
865 895 | /// When additional tokens are found past where we expect the end of the body,
|
866 896 | /// the request should be rejected with a serialization exception.
|
867 897 | /// Test ID: AdditionalTokensEmptyStruct
|
868 898 | #[::tokio::test]
|
869 899 | #[::tracing_test::traced_test]
|
870 900 | #[should_panic]
|
871 901 | async fn additional_tokens_empty_struct_malformed_request() {
|
872 902 | {
|
873 903 | #[allow(unused_mut)]
|
874 - | let mut http_request = http::Request::builder()
|
904 + | let mut http_request = ::http_1x::Request::builder()
|
875 905 | .uri("/service/RpcV2CborService/operation/EmptyStructOperation")
|
876 906 | .method("POST")
|
877 907 | .header("smithy-protocol", "rpc-v2-cbor")
|
878 908 | .header("Accept", "application/cbor")
|
879 909 | .header("Content-Type", "application/cbor")
|
880 - | .body(::aws_smithy_http_server::body::Body::from(
|
881 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
910 + | .body(::aws_smithy_http_server::body::boxed(
|
911 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
912 + | &::aws_smithy_protocol_test::decode_body_data(
|
882 913 | "v/+//w==".as_bytes(),
|
883 914 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
915 + | ),
|
884 916 | )),
|
885 917 | ))
|
886 918 | .unwrap();
|
887 919 | #[allow(unused_mut)]
|
888 920 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
889 921 | let config = crate::service::RpcV2CborServiceConfig::builder().build();
|
890 - | let service = crate::service::RpcV2CborService::builder::<::hyper::body::Body, _, _, _>(config)
|
922 + | let service = crate::service::RpcV2CborService::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
891 923 | .empty_struct_operation(move |input: crate::input::EmptyStructOperationInput| {
|
892 924 | let sender = sender.clone();
|
893 925 | async move {
|
894 926 | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as crate::output::EmptyStructOperationOutput };
|
895 927 | sender.send(()).await.expect("receiver dropped early");
|
896 928 | result
|
897 929 | }
|
898 930 | })
|
899 931 | .build_unchecked();
|
900 932 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
901 933 | .await
|
902 934 | .expect("unable to make an HTTP request");
|
903 935 | ::pretty_assertions::assert_eq!(
|
904 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
936 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
905 937 | http_response.status()
|
906 938 | );
|
907 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
939 + | use ::http_body_util::BodyExt;
|
940 + | let body = http_response
|
941 + | .into_body()
|
942 + | .collect()
|
908 943 | .await
|
909 - | .expect("unable to extract body to bytes");
|
944 + | .expect("unable to collect body")
|
945 + | .to_bytes();
|
910 946 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
911 947 | &body,
|
912 948 | "oA==",
|
913 949 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
914 950 | ));
|
915 951 | }
|
916 952 | }
|
917 953 | }
|
918 954 |
|
919 955 | ::pin_project_lite::pin_project! {
|
920 956 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
921 957 | /// [`ComplexStructOperationInput`](crate::input::ComplexStructOperationInput) using modelled bindings.
|
922 958 | pub struct ComplexStructOperationInputFuture {
|
923 959 | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::ComplexStructOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
924 960 | }
|
925 961 | }
|
926 962 |
|
927 963 | impl std::future::Future for ComplexStructOperationInputFuture {
|
928 964 | type Output = Result<
|
929 965 | crate::input::ComplexStructOperationInput,
|
930 966 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
931 967 | >;
|
932 968 |
|
933 969 | fn poll(
|
934 970 | self: std::pin::Pin<&mut Self>,
|
935 971 | cx: &mut std::task::Context<'_>,
|
936 972 | ) -> std::task::Poll<Self::Output> {
|
937 973 | let this = self.project();
|
938 974 | this.inner.as_mut().poll(cx)
|
939 975 | }
|
940 976 | }
|
941 977 |
|
942 978 | impl<B>
|
943 979 | ::aws_smithy_http_server::request::FromRequest<
|
944 980 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
945 981 | B,
|
946 982 | > for crate::input::ComplexStructOperationInput
|
947 983 | where
|
948 984 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
949 985 | B: 'static,
|
950 986 |
|
951 987 | B::Data: Send,
|
952 988 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
953 989 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
954 990 | {
|
955 991 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
956 992 | type Future = ComplexStructOperationInputFuture;
|
957 993 |
|
958 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
994 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
959 995 | let fut = async move {
|
960 996 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
961 997 | request.headers(),
|
962 998 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
963 999 | ) {
|
964 1000 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
965 1001 | }
|
966 1002 | crate::protocol_serde::shape_complex_struct_operation::de_complex_struct_operation_http_request(request)
|
967 1003 | .await
|
968 1004 | };
|
1127 1163 | async fn operation_output_serialization_questionably_includes_type_field_response() {
|
1128 1164 | let output = crate::output::ErrorSerializationOperationOutput {
|
1129 1165 | error_shape: ::std::option::Option::Some(crate::error::ValidationException {
|
1130 1166 | message: "ValidationException message field".to_owned(),
|
1131 1167 | field_list: ::std::option::Option::None,
|
1132 1168 | }),
|
1133 1169 | };
|
1134 1170 | use ::aws_smithy_http_server::response::IntoResponse;
|
1135 1171 | let http_response = output.into_response();
|
1136 1172 | ::pretty_assertions::assert_eq!(
|
1137 - | http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1173 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1138 1174 | http_response.status()
|
1139 1175 | );
|
1140 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1176 + | use ::http_body_util::BodyExt;
|
1177 + | let body = http_response
|
1178 + | .into_body()
|
1179 + | .collect()
|
1141 1180 | .await
|
1142 - | .expect("unable to extract body to bytes");
|
1181 + | .expect("unable to collect body")
|
1182 + | .to_bytes();
|
1143 1183 | ::aws_smithy_protocol_test::assert_ok(
|
1144 1184 | ::aws_smithy_protocol_test::validate_body(&body, "v2plcnJvclNoYXBlv2ZfX3R5cGV4JHNtaXRoeS5mcmFtZXdvcmsjVmFsaWRhdGlvbkV4Y2VwdGlvbmdtZXNzYWdleCFWYWxpZGF0aW9uRXhjZXB0aW9uIG1lc3NhZ2UgZmllbGT//w==", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1145 1185 | );
|
1146 1186 | }
|
1147 1187 |
|
1148 1188 | /// When invalid input is provided the request should be rejected with
|
1149 1189 | /// a validation exception, and a `__type` field should be included
|
1150 1190 | /// Test ID: ErrorSerializationIncludesTypeField
|
1151 1191 | #[::tokio::test]
|
1152 1192 | #[::tracing_test::traced_test]
|
1153 1193 | async fn error_serialization_includes_type_field_malformed_request() {
|
1154 1194 | {
|
1155 1195 | #[allow(unused_mut)]
|
1156 - | let mut http_request = http::Request::builder()
|
1196 + | let mut http_request = ::http_1x::Request::builder()
|
1157 1197 | .uri("/service/RpcV2CborService/operation/ErrorSerializationOperation")
|
1158 1198 | .method("POST")
|
1159 1199 | .header("smithy-protocol", "rpc-v2-cbor")
|
1160 1200 | .header("Accept", "application/cbor")
|
1161 1201 | .header("Content-Type", "application/cbor")
|
1162 - | .body(::aws_smithy_http_server::body::Body::from(
|
1163 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1202 + | .body(::aws_smithy_http_server::body::boxed(
|
1203 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1204 + | &::aws_smithy_protocol_test::decode_body_data(
|
1164 1205 | "oA==".as_bytes(),
|
1165 1206 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1207 + | ),
|
1166 1208 | )),
|
1167 1209 | ))
|
1168 1210 | .unwrap();
|
1169 1211 | #[allow(unused_mut)]
|
1170 1212 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1171 1213 | let config = crate::service::RpcV2CborServiceConfig::builder().build();
|
1172 - | let service = crate::service::RpcV2CborService::builder::<::hyper::body::Body, _, _, _>(config)
|
1214 + | let service = crate::service::RpcV2CborService::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1173 1215 | .error_serialization_operation(move |input: crate::input::ErrorSerializationOperationInput| {
|
1174 1216 | let sender = sender.clone();
|
1175 1217 | async move {
|
1176 1218 | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::ErrorSerializationOperationOutput, crate::error::ErrorSerializationOperationError> };
|
1177 1219 | sender.send(()).await.expect("receiver dropped early");
|
1178 1220 | result
|
1179 1221 | }
|
1180 1222 | })
|
1181 1223 | .build_unchecked();
|
1182 1224 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1183 1225 | .await
|
1184 1226 | .expect("unable to make an HTTP request");
|
1185 1227 | ::pretty_assertions::assert_eq!(
|
1186 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1228 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1187 1229 | http_response.status()
|
1188 1230 | );
|
1189 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1231 + | use ::http_body_util::BodyExt;
|
1232 + | let body = http_response
|
1233 + | .into_body()
|
1234 + | .collect()
|
1190 1235 | .await
|
1191 - | .expect("unable to extract body to bytes");
|
1236 + | .expect("unable to collect body")
|
1237 + | .to_bytes();
|
1192 1238 | ::aws_smithy_protocol_test::assert_ok(
|
1193 1239 | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4JHNtaXRoeS5mcmFtZXdvcmsjVmFsaWRhdGlvbkV4Y2VwdGlvbmdtZXNzYWdleGsxIHZhbGlkYXRpb24gZXJyb3IgZGV0ZWN0ZWQuIFZhbHVlIGF0ICcvcmVxdWlyZWRCbG9iJyBmYWlsZWQgdG8gc2F0aXNmeSBjb25zdHJhaW50OiBNZW1iZXIgbXVzdCBub3QgYmUgbnVsbGlmaWVsZExpc3SBv2RwYXRobS9yZXF1aXJlZEJsb2JnbWVzc2FnZXhOVmFsdWUgYXQgJy9yZXF1aXJlZEJsb2InIGZhaWxlZCB0byBzYXRpc2Z5IGNvbnN0cmFpbnQ6IE1lbWJlciBtdXN0IG5vdCBiZSBudWxs//8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1194 1240 | );
|
1195 1241 | }
|
1196 1242 | }
|
1197 1243 | }
|
1198 1244 |
|
1199 1245 | ::pin_project_lite::pin_project! {
|
1200 1246 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1201 1247 | /// [`SimpleStructOperationInput`](crate::input::SimpleStructOperationInput) using modelled bindings.
|
1202 1248 | pub struct SimpleStructOperationInputFuture {
|
1203 1249 | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SimpleStructOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
1204 1250 | }
|
1205 1251 | }
|
1206 1252 |
|
1207 1253 | impl std::future::Future for SimpleStructOperationInputFuture {
|
1208 1254 | type Output = Result<
|
1209 1255 | crate::input::SimpleStructOperationInput,
|
1210 1256 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
1211 1257 | >;
|
1212 1258 |
|
1213 1259 | fn poll(
|
1214 1260 | self: std::pin::Pin<&mut Self>,
|
1215 1261 | cx: &mut std::task::Context<'_>,
|
1216 1262 | ) -> std::task::Poll<Self::Output> {
|
1217 1263 | let this = self.project();
|
1218 1264 | this.inner.as_mut().poll(cx)
|
1219 1265 | }
|
1220 1266 | }
|
1221 1267 |
|
1222 1268 | impl<B>
|
1223 1269 | ::aws_smithy_http_server::request::FromRequest<
|
1224 1270 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1225 1271 | B,
|
1226 1272 | > for crate::input::SimpleStructOperationInput
|
1227 1273 | where
|
1228 1274 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
1229 1275 | B: 'static,
|
1230 1276 |
|
1231 1277 | B::Data: Send,
|
1232 1278 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
1233 1279 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
1234 1280 | {
|
1235 1281 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
1236 1282 | type Future = SimpleStructOperationInputFuture;
|
1237 1283 |
|
1238 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1284 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
1239 1285 | let fut = async move {
|
1240 1286 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1241 1287 | request.headers(),
|
1242 1288 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
1243 1289 | ) {
|
1244 1290 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
1245 1291 | }
|
1246 1292 | crate::protocol_serde::shape_simple_struct_operation::de_simple_struct_operation_http_request(request)
|
1247 1293 | .await
|
1248 1294 | };
|