Client Test

Client Test

rev. a25ccedd311e7562a03a1cd07d728cef10c9474c

Files changed:

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/operation/null_and_empty_headers_client.rs

@@ -200,200 +280,278 @@
  220    220   
    }
  221    221   
}
  222    222   
  223    223   
// The get_* functions below are generated from JMESPath expressions in the
  224    224   
// operationContextParams trait. They target the operation's input shape.
  225    225   
  226    226   
#[allow(unreachable_code, unused_variables)]
  227    227   
#[cfg(test)]
  228    228   
mod null_and_empty_headers_client_test {
  229    229   
  230         -
    /// Do not send null values, but do send empty strings and empty lists over the wire in headers
         230  +
    /// Do not send null values, empty strings, or empty lists over the wire in headers
  231    231   
    /// Test ID: NullAndEmptyHeaders
  232    232   
    #[::tokio::test]
  233    233   
    #[::tracing_test::traced_test]
  234    234   
    async fn null_and_empty_headers_request() {
  235    235   
        let (http_client, request_receiver) = ::aws_smithy_runtime::client::http::test_util::capture_request(None);
  236    236   
        let config_builder = crate::config::Config::builder().with_test_defaults().endpoint_url("https://example.com");
  237    237   
  238    238   
        let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
  239    239   
        let result = client
  240    240   
            .null_and_empty_headers_client()
  241    241   
            .set_a(::std::option::Option::None)
  242    242   
            .set_b(::std::option::Option::Some("".to_owned()))
  243    243   
            .set_c(::std::option::Option::Some(vec![]))
  244    244   
            .send()
  245    245   
            .await;
  246    246   
        let _ = dbg!(result);
  247    247   
        let http_request = request_receiver.expect_request();
  248         -
        let expected_headers = [("X-B", ""), ("X-C", "")];
  249         -
        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
  250         -
        let forbidden_headers = &["X-A"];
         248  +
        let forbidden_headers = &["X-A", "X-B", "X-C"];
  251    249   
        ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::forbid_headers(http_request.headers(), forbidden_headers));
  252    250   
        let body = http_request.body().bytes().expect("body should be strict");
  253    251   
        // No body.
  254    252   
        ::pretty_assertions::assert_eq!(&body, &bytes::Bytes::new());
  255    253   
        let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
  256    254   
        ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
  257    255   
        ::pretty_assertions::assert_eq!(uri.path(), "/NullAndEmptyHeadersClient", "path was incorrect");
  258    256   
    }
  259    257   
}
  260    258   

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde.rs

@@ -90,90 +151,149 @@
  110    110   
pub(crate) mod shape_http_response_code;
  111    111   
  112    112   
pub(crate) mod shape_http_string_payload;
  113    113   
  114    114   
pub(crate) mod shape_http_string_payload_input;
  115    115   
  116    116   
pub(crate) mod shape_ignore_query_params_in_response;
  117    117   
  118    118   
pub(crate) mod shape_input_and_output_with_headers;
  119    119   
  120         -
pub(crate) mod shape_nested_xml_map_with_xml_name;
  121         -
  122    120   
pub(crate) mod shape_nested_xml_maps;
  123    121   
  124    122   
pub(crate) mod shape_no_input_and_no_output;
  125    123   
  126    124   
pub(crate) mod shape_no_input_and_output;
  127    125   
  128    126   
pub(crate) mod shape_null_and_empty_headers_client;
  129    127   
  130    128   
pub(crate) mod shape_null_and_empty_headers_server;
  131    129   
@@ -192,190 +253,249 @@
  212    210   
pub(crate) mod shape_http_payload_with_xml_namespace_output;
  213    211   
  214    212   
pub(crate) mod shape_http_prefix_headers_output;
  215    213   
  216    214   
pub(crate) mod shape_http_string_payload_output;
  217    215   
  218    216   
pub(crate) mod shape_input_and_output_with_headers_output;
  219    217   
  220    218   
pub(crate) mod shape_invalid_greeting;
  221    219   
  222         -
pub(crate) mod shape_nested_xml_map_with_xml_name_input;
  223         -
  224    220   
pub(crate) mod shape_nested_xml_maps_input;
  225    221   
  226    222   
pub(crate) mod shape_null_and_empty_headers_client_output;
  227    223   
  228    224   
pub(crate) mod shape_null_and_empty_headers_server_output;
  229    225   
  230    226   
pub(crate) mod shape_put_with_content_encoding_input;
  231    227   
  232    228   
pub(crate) mod shape_recursive_shapes_input;
  233    229   
@@ -272,268 +346,0 @@
  292    288   
pub(crate) mod shape_integer_enum_set;
  293    289   
  294    290   
pub(crate) mod shape_integer_list;
  295    291   
  296    292   
pub(crate) mod shape_nested_map;
  297    293   
  298    294   
pub(crate) mod shape_nested_payload;
  299    295   
  300    296   
pub(crate) mod shape_nested_string_list;
  301    297   
  302         -
pub(crate) mod shape_nested_xml_map_with_xml_name_map;
  303         -
  304    298   
pub(crate) mod shape_payload_with_xml_name;
  305    299   
  306    300   
pub(crate) mod shape_payload_with_xml_namespace;
  307    301   
  308    302   
pub(crate) mod shape_payload_with_xml_namespace_and_prefix;
  309    303   
  310    304   
pub(crate) mod shape_recursive_shapes_input_output_nested1;
  311    305   
  312    306   
pub(crate) mod shape_renamed_list_members;
  313    307   
  314    308   
pub(crate) mod shape_string_list;
  315    309   
  316    310   
pub(crate) mod shape_string_set;
  317    311   
  318    312   
pub(crate) mod shape_structure_list;
  319    313   
  320    314   
pub(crate) mod shape_structure_list_member;
  321    315   
  322    316   
pub(crate) mod shape_timestamp_list;
  323    317   
  324    318   
pub(crate) mod shape_union_payload;
  325    319   
  326    320   
pub(crate) mod shape_xml_attributes_payload_request;
  327    321   
  328    322   
pub(crate) mod shape_xml_map_with_xml_namespace_input_output_map;
  329    323   
  330    324   
pub(crate) mod shape_xml_maps_input_output_map;
  331    325   
  332    326   
pub(crate) mod shape_xml_maps_xml_name_input_output_map;
  333    327   
  334    328   
pub(crate) mod shape_xml_namespace_nested;
  335    329   
  336    330   
pub(crate) mod shape_xml_union_shape;
  337    331   
  338    332   
pub(crate) mod shape_recursive_shapes_input_output_nested2;
  339    333   
  340    334   
pub(crate) mod shape_xml_attributes_payload_response;
  341    335   
  342    336   
pub(crate) mod shape_xml_namespaced_list;
  343    337   
  344    338   
pub(crate) mod shape_xml_nested_union_struct;
  345         -
  346         -
pub(crate) mod shape_nested_xml_map_with_xml_name_inner_map;

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde/shape_endpoint_with_host_label_header_operation.rs

@@ -11,11 +51,53 @@
   31     31   
        output.build()
   32     32   
    })
   33     33   
}
   34     34   
   35     35   
pub fn ser_endpoint_with_host_label_header_operation_headers(
   36     36   
    input: &crate::operation::endpoint_with_host_label_header_operation::EndpointWithHostLabelHeaderOperationInput,
   37     37   
    mut builder: ::http::request::Builder,
   38     38   
) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
   39     39   
    if let ::std::option::Option::Some(inner_1) = &input.account_id {
   40     40   
        let formatted_2 = inner_1.as_str();
   41         -
        let header_value = formatted_2;
   42         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   43         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
   44         -
                "account_id",
   45         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
   46         -
            )
   47         -
        })?;
   48         -
        builder = builder.header("X-Amz-Account-Id", header_value);
          41  +
        if !formatted_2.is_empty() {
          42  +
            let header_value = formatted_2;
          43  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
          44  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
          45  +
                    "account_id",
          46  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
          47  +
                )
          48  +
            })?;
          49  +
            builder = builder.header("X-Amz-Account-Id", header_value);
          50  +
        }
   49     51   
    }
   50     52   
    Ok(builder)
   51     53   
}

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde/shape_http_payload_traits.rs

@@ -11,11 +51,53 @@
   31     31   
        output.build()
   32     32   
    })
   33     33   
}
   34     34   
   35     35   
pub fn ser_http_payload_traits_headers(
   36     36   
    input: &crate::operation::http_payload_traits::HttpPayloadTraitsInput,
   37     37   
    mut builder: ::http::request::Builder,
   38     38   
) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
   39     39   
    if let ::std::option::Option::Some(inner_1) = &input.foo {
   40     40   
        let formatted_2 = inner_1.as_str();
   41         -
        let header_value = formatted_2;
   42         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   43         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
   44         -
                "foo",
   45         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
   46         -
            )
   47         -
        })?;
   48         -
        builder = builder.header("X-Foo", header_value);
          41  +
        if !formatted_2.is_empty() {
          42  +
            let header_value = formatted_2;
          43  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
          44  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
          45  +
                    "foo",
          46  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
          47  +
                )
          48  +
            })?;
          49  +
            builder = builder.header("X-Foo", header_value);
          50  +
        }
   49     51   
    }
   50     52   
    Ok(builder)
   51     53   
}

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde/shape_http_payload_traits_with_media_type.rs

@@ -20,20 +60,62 @@
   40     40   
        output.build()
   41     41   
    })
   42     42   
}
   43     43   
   44     44   
pub fn ser_http_payload_traits_with_media_type_headers(
   45     45   
    input: &crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeInput,
   46     46   
    mut builder: ::http::request::Builder,
   47     47   
) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
   48     48   
    if let ::std::option::Option::Some(inner_1) = &input.foo {
   49     49   
        let formatted_2 = inner_1.as_str();
   50         -
        let header_value = formatted_2;
   51         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   52         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
   53         -
                "foo",
   54         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
   55         -
            )
   56         -
        })?;
   57         -
        builder = builder.header("X-Foo", header_value);
          50  +
        if !formatted_2.is_empty() {
          51  +
            let header_value = formatted_2;
          52  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
          53  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
          54  +
                    "foo",
          55  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
          56  +
                )
          57  +
            })?;
          58  +
            builder = builder.header("X-Foo", header_value);
          59  +
        }
   58     60   
    }
   59     61   
    Ok(builder)
   60     62   
}

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde/shape_http_prefix_headers.rs

@@ -15,15 +76,78 @@
   35     35   
        output.build()
   36     36   
    })
   37     37   
}
   38     38   
   39     39   
pub fn ser_http_prefix_headers_headers(
   40     40   
    input: &crate::operation::http_prefix_headers::HttpPrefixHeadersInput,
   41     41   
    mut builder: ::http::request::Builder,
   42     42   
) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
   43     43   
    if let ::std::option::Option::Some(inner_1) = &input.foo {
   44     44   
        let formatted_2 = inner_1.as_str();
   45         -
        let header_value = formatted_2;
   46         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   47         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
   48         -
                "foo",
   49         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
   50         -
            )
   51         -
        })?;
   52         -
        builder = builder.header("X-Foo", header_value);
          45  +
        if !formatted_2.is_empty() {
          46  +
            let header_value = formatted_2;
          47  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
          48  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
          49  +
                    "foo",
          50  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
          51  +
                )
          52  +
            })?;
          53  +
            builder = builder.header("X-Foo", header_value);
          54  +
        }
   53     55   
    }
   54     56   
    if let ::std::option::Option::Some(inner_3) = &input.foo_map {
   55     57   
        {
   56     58   
            for (k, v) in inner_3 {
   57     59   
                use std::str::FromStr;
   58     60   
                let header_name = http::header::HeaderName::from_str(&format!("{}{}", "X-Foo-", &k)).map_err(|err| {
   59     61   
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
   60     62   
                        "foo_map",
   61     63   
                        format!("`{k}` cannot be used as a header name: {err}"),
   62     64   
                    )

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde/shape_input_and_output_with_headers.rs

@@ -124,124 +381,383 @@
  144    144   
        output.build()
  145    145   
    })
  146    146   
}
  147    147   
  148    148   
pub fn ser_input_and_output_with_headers_headers(
  149    149   
    input: &crate::operation::input_and_output_with_headers::InputAndOutputWithHeadersInput,
  150    150   
    mut builder: ::http::request::Builder,
  151    151   
) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
  152    152   
    if let ::std::option::Option::Some(inner_1) = &input.header_string {
  153    153   
        let formatted_2 = inner_1.as_str();
  154         -
        let header_value = formatted_2;
  155         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  156         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  157         -
                "header_string",
  158         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  159         -
            )
  160         -
        })?;
  161         -
        builder = builder.header("X-String", header_value);
         154  +
        if !formatted_2.is_empty() {
         155  +
            let header_value = formatted_2;
         156  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         157  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         158  +
                    "header_string",
         159  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         160  +
                )
         161  +
            })?;
         162  +
            builder = builder.header("X-String", header_value);
         163  +
        }
  162    164   
    }
  163    165   
    if let ::std::option::Option::Some(inner_3) = &input.header_byte {
  164    166   
        let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_3);
  165    167   
        let formatted_4 = encoder.encode();
  166         -
        let header_value = formatted_4;
  167         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  168         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  169         -
                "header_byte",
  170         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  171         -
            )
  172         -
        })?;
  173         -
        builder = builder.header("X-Byte", header_value);
         168  +
        if !formatted_4.is_empty() {
         169  +
            let header_value = formatted_4;
         170  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         171  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         172  +
                    "header_byte",
         173  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         174  +
                )
         175  +
            })?;
         176  +
            builder = builder.header("X-Byte", header_value);
         177  +
        }
  174    178   
    }
  175    179   
    if let ::std::option::Option::Some(inner_5) = &input.header_short {
  176    180   
        let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_5);
  177    181   
        let formatted_6 = encoder.encode();
  178         -
        let header_value = formatted_6;
  179         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  180         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  181         -
                "header_short",
  182         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  183         -
            )
  184         -
        })?;
  185         -
        builder = builder.header("X-Short", header_value);
         182  +
        if !formatted_6.is_empty() {
         183  +
            let header_value = formatted_6;
         184  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         185  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         186  +
                    "header_short",
         187  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         188  +
                )
         189  +
            })?;
         190  +
            builder = builder.header("X-Short", header_value);
         191  +
        }
  186    192   
    }
  187    193   
    if let ::std::option::Option::Some(inner_7) = &input.header_integer {
  188    194   
        let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_7);
  189    195   
        let formatted_8 = encoder.encode();
  190         -
        let header_value = formatted_8;
  191         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  192         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  193         -
                "header_integer",
  194         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  195         -
            )
  196         -
        })?;
  197         -
        builder = builder.header("X-Integer", header_value);
         196  +
        if !formatted_8.is_empty() {
         197  +
            let header_value = formatted_8;
         198  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         199  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         200  +
                    "header_integer",
         201  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         202  +
                )
         203  +
            })?;
         204  +
            builder = builder.header("X-Integer", header_value);
         205  +
        }
  198    206   
    }
  199    207   
    if let ::std::option::Option::Some(inner_9) = &input.header_long {
  200    208   
        let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_9);
  201    209   
        let formatted_10 = encoder.encode();
  202         -
        let header_value = formatted_10;
  203         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  204         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  205         -
                "header_long",
  206         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  207         -
            )
  208         -
        })?;
  209         -
        builder = builder.header("X-Long", header_value);
         210  +
        if !formatted_10.is_empty() {
         211  +
            let header_value = formatted_10;
         212  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         213  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         214  +
                    "header_long",
         215  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         216  +
                )
         217  +
            })?;
         218  +
            builder = builder.header("X-Long", header_value);
         219  +
        }
  210    220   
    }
  211    221   
    if let ::std::option::Option::Some(inner_11) = &input.header_float {
  212    222   
        let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_11);
  213    223   
        let formatted_12 = encoder.encode();
  214         -
        let header_value = formatted_12;
  215         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  216         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  217         -
                "header_float",
  218         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  219         -
            )
  220         -
        })?;
  221         -
        builder = builder.header("X-Float", header_value);
         224  +
        if !formatted_12.is_empty() {
         225  +
            let header_value = formatted_12;
         226  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         227  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         228  +
                    "header_float",
         229  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         230  +
                )
         231  +
            })?;
         232  +
            builder = builder.header("X-Float", header_value);
         233  +
        }
  222    234   
    }
  223    235   
    if let ::std::option::Option::Some(inner_13) = &input.header_double {
  224    236   
        let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_13);
  225    237   
        let formatted_14 = encoder.encode();
  226         -
        let header_value = formatted_14;
  227         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  228         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  229         -
                "header_double",
  230         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  231         -
            )
  232         -
        })?;
  233         -
        builder = builder.header("X-Double", header_value);
         238  +
        if !formatted_14.is_empty() {
         239  +
            let header_value = formatted_14;
         240  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         241  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         242  +
                    "header_double",
         243  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         244  +
                )
         245  +
            })?;
         246  +
            builder = builder.header("X-Double", header_value);
         247  +
        }
  234    248   
    }
  235    249   
    if let ::std::option::Option::Some(inner_15) = &input.header_true_bool {
  236    250   
        let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_15);
  237    251   
        let formatted_16 = encoder.encode();
  238         -
        let header_value = formatted_16;
  239         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  240         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  241         -
                "header_true_bool",
  242         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  243         -
            )
  244         -
        })?;
  245         -
        builder = builder.header("X-Boolean1", header_value);
         252  +
        if !formatted_16.is_empty() {
         253  +
            let header_value = formatted_16;
         254  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         255  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         256  +
                    "header_true_bool",
         257  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         258  +
                )
         259  +
            })?;
         260  +
            builder = builder.header("X-Boolean1", header_value);
         261  +
        }
  246    262   
    }
  247    263   
    if let ::std::option::Option::Some(inner_17) = &input.header_false_bool {
  248    264   
        let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_17);
  249    265   
        let formatted_18 = encoder.encode();
  250         -
        let header_value = formatted_18;
  251         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  252         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  253         -
                "header_false_bool",
  254         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  255         -
            )
  256         -
        })?;
  257         -
        builder = builder.header("X-Boolean2", header_value);
         266  +
        if !formatted_18.is_empty() {
         267  +
            let header_value = formatted_18;
         268  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         269  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         270  +
                    "header_false_bool",
         271  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         272  +
                )
         273  +
            })?;
         274  +
            builder = builder.header("X-Boolean2", header_value);
         275  +
        }
  258    276   
    }
  259    277   
    if let ::std::option::Option::Some(inner_19) = &input.header_string_list {
  260         -
        // Empty vec in header is serialized as an empty string
  261         -
        if inner_19.is_empty() {
  262         -
            builder = builder.header("X-StringList", "");
  263         -
        } else {
  264         -
            for inner_20 in inner_19 {
  265         -
                let formatted_21 = ::aws_smithy_http::header::quote_header_value(inner_20.as_str());
         278  +
        for inner_20 in inner_19 {
         279  +
            let formatted_21 = ::aws_smithy_http::header::quote_header_value(inner_20.as_str());
         280  +
            if !formatted_21.is_empty() {
  266    281   
                let header_value = formatted_21;
  267    282   
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  268    283   
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
  269    284   
                        "header_string_list",
  270    285   
                        format!("`{}` cannot be used as a header value: {}", &header_value, err),
  271    286   
                    )
  272    287   
                })?;
  273    288   
                builder = builder.header("X-StringList", header_value);
  274    289   
            }
  275    290   
        }
  276    291   
    }
  277    292   
    if let ::std::option::Option::Some(inner_22) = &input.header_string_set {
  278         -
        // Empty vec in header is serialized as an empty string
  279         -
        if inner_22.is_empty() {
  280         -
            builder = builder.header("X-StringSet", "");
  281         -
        } else {
  282         -
            for inner_23 in inner_22 {
  283         -
                let formatted_24 = ::aws_smithy_http::header::quote_header_value(inner_23.as_str());
         293  +
        for inner_23 in inner_22 {
         294  +
            let formatted_24 = ::aws_smithy_http::header::quote_header_value(inner_23.as_str());
         295  +
            if !formatted_24.is_empty() {
  284    296   
                let header_value = formatted_24;
  285    297   
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  286    298   
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
  287    299   
                        "header_string_set",
  288    300   
                        format!("`{}` cannot be used as a header value: {}", &header_value, err),
  289    301   
                    )
  290    302   
                })?;
  291    303   
                builder = builder.header("X-StringSet", header_value);
  292    304   
            }
  293    305   
        }
  294    306   
    }
  295    307   
    if let ::std::option::Option::Some(inner_25) = &input.header_integer_list {
  296         -
        // Empty vec in header is serialized as an empty string
  297         -
        if inner_25.is_empty() {
  298         -
            builder = builder.header("X-IntegerList", "");
  299         -
        } else {
  300         -
            for inner_26 in inner_25 {
  301         -
                let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_26);
  302         -
                let formatted_27 = encoder.encode();
         308  +
        for inner_26 in inner_25 {
         309  +
            let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_26);
         310  +
            let formatted_27 = encoder.encode();
         311  +
            if !formatted_27.is_empty() {
  303    312   
                let header_value = formatted_27;
  304    313   
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  305    314   
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
  306    315   
                        "header_integer_list",
  307    316   
                        format!("`{}` cannot be used as a header value: {}", &header_value, err),
  308    317   
                    )
  309    318   
                })?;
  310    319   
                builder = builder.header("X-IntegerList", header_value);
  311    320   
            }
  312    321   
        }
  313    322   
    }
  314    323   
    if let ::std::option::Option::Some(inner_28) = &input.header_boolean_list {
  315         -
        // Empty vec in header is serialized as an empty string
  316         -
        if inner_28.is_empty() {
  317         -
            builder = builder.header("X-BooleanList", "");
  318         -
        } else {
  319         -
            for inner_29 in inner_28 {
  320         -
                let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_29);
  321         -
                let formatted_30 = encoder.encode();
         324  +
        for inner_29 in inner_28 {
         325  +
            let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_29);
         326  +
            let formatted_30 = encoder.encode();
         327  +
            if !formatted_30.is_empty() {
  322    328   
                let header_value = formatted_30;
  323    329   
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  324    330   
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
  325    331   
                        "header_boolean_list",
  326    332   
                        format!("`{}` cannot be used as a header value: {}", &header_value, err),
  327    333   
                    )
  328    334   
                })?;
  329    335   
                builder = builder.header("X-BooleanList", header_value);
  330    336   
            }
  331    337   
        }
  332    338   
    }
  333    339   
    if let ::std::option::Option::Some(inner_31) = &input.header_timestamp_list {
  334         -
        // Empty vec in header is serialized as an empty string
  335         -
        if inner_31.is_empty() {
  336         -
            builder = builder.header("X-TimestampList", "");
  337         -
        } else {
  338         -
            for inner_32 in inner_31 {
  339         -
                let formatted_33 = inner_32.fmt(::aws_smithy_types::date_time::Format::HttpDate)?;
         340  +
        for inner_32 in inner_31 {
         341  +
            let formatted_33 = inner_32.fmt(::aws_smithy_types::date_time::Format::HttpDate)?;
         342  +
            if !formatted_33.is_empty() {
  340    343   
                let header_value = formatted_33;
  341    344   
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  342    345   
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
  343    346   
                        "header_timestamp_list",
  344    347   
                        format!("`{}` cannot be used as a header value: {}", &header_value, err),
  345    348   
                    )
  346    349   
                })?;
  347    350   
                builder = builder.header("X-TimestampList", header_value);
  348    351   
            }
  349    352   
        }
  350    353   
    }
  351    354   
    if let ::std::option::Option::Some(inner_34) = &input.header_enum {
  352    355   
        let formatted_35 = inner_34.as_str();
  353         -
        let header_value = formatted_35;
  354         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  355         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  356         -
                "header_enum",
  357         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  358         -
            )
  359         -
        })?;
  360         -
        builder = builder.header("X-Enum", header_value);
         356  +
        if !formatted_35.is_empty() {
         357  +
            let header_value = formatted_35;
         358  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         359  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         360  +
                    "header_enum",
         361  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         362  +
                )
         363  +
            })?;
         364  +
            builder = builder.header("X-Enum", header_value);
         365  +
        }
  361    366   
    }
  362    367   
    if let ::std::option::Option::Some(inner_36) = &input.header_enum_list {
  363         -
        // Empty vec in header is serialized as an empty string
  364         -
        if inner_36.is_empty() {
  365         -
            builder = builder.header("X-EnumList", "");
  366         -
        } else {
  367         -
            for inner_37 in inner_36 {
  368         -
                let formatted_38 = ::aws_smithy_http::header::quote_header_value(inner_37.as_str());
         368  +
        for inner_37 in inner_36 {
         369  +
            let formatted_38 = ::aws_smithy_http::header::quote_header_value(inner_37.as_str());
         370  +
            if !formatted_38.is_empty() {
  369    371   
                let header_value = formatted_38;
  370    372   
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  371    373   
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
  372    374   
                        "header_enum_list",
  373    375   
                        format!("`{}` cannot be used as a header value: {}", &header_value, err),
  374    376   
                    )
  375    377   
                })?;
  376    378   
                builder = builder.header("X-EnumList", header_value);
  377    379   
            }
  378    380   
        }

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde/shape_nested_xml_map_with_xml_name.rs

@@ -1,0 +85,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
#[allow(clippy::unnecessary_wraps)]
    3         -
pub fn de_nested_xml_map_with_xml_name_http_error(
    4         -
    _response_status: u16,
    5         -
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
    6         -
    _response_body: &[u8],
    7         -
) -> std::result::Result<
    8         -
    crate::operation::nested_xml_map_with_xml_name::NestedXmlMapWithXmlNameOutput,
    9         -
    crate::operation::nested_xml_map_with_xml_name::NestedXmlMapWithXmlNameError,
   10         -
> {
   11         -
    #[allow(unused_mut)]
   12         -
    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
   13         -
        .map_err(crate::operation::nested_xml_map_with_xml_name::NestedXmlMapWithXmlNameError::unhandled)?;
   14         -
    let generic = generic_builder.build();
   15         -
    Err(crate::operation::nested_xml_map_with_xml_name::NestedXmlMapWithXmlNameError::generic(
   16         -
        generic,
   17         -
    ))
   18         -
}
   19         -
   20         -
#[allow(clippy::unnecessary_wraps)]
   21         -
pub fn de_nested_xml_map_with_xml_name_http_response(
   22         -
    _response_status: u16,
   23         -
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
   24         -
    _response_body: &[u8],
   25         -
) -> std::result::Result<
   26         -
    crate::operation::nested_xml_map_with_xml_name::NestedXmlMapWithXmlNameOutput,
   27         -
    crate::operation::nested_xml_map_with_xml_name::NestedXmlMapWithXmlNameError,
   28         -
> {
   29         -
    Ok({
   30         -
        #[allow(unused_mut)]
   31         -
        let mut output = crate::operation::nested_xml_map_with_xml_name::builders::NestedXmlMapWithXmlNameOutputBuilder::default();
   32         -
        output = crate::protocol_serde::shape_nested_xml_map_with_xml_name::de_nested_xml_map_with_xml_name(_response_body, output)
   33         -
            .map_err(crate::operation::nested_xml_map_with_xml_name::NestedXmlMapWithXmlNameError::unhandled)?;
   34         -
        output.build()
   35         -
    })
   36         -
}
   37         -
   38         -
pub fn ser_nested_xml_map_with_xml_name_op_input(
   39         -
    input: &crate::operation::nested_xml_map_with_xml_name::NestedXmlMapWithXmlNameInput,
   40         -
) -> Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
   41         -
    let mut out = String::new();
   42         -
    {
   43         -
        let mut writer = ::aws_smithy_xml::encode::XmlWriter::new(&mut out);
   44         -
        #[allow(unused_mut)]
   45         -
        let mut root = writer.start_el("NestedXmlMapWithXmlNameInputOutput");
   46         -
        crate::protocol_serde::shape_nested_xml_map_with_xml_name_input::ser_nested_xml_map_with_xml_name_input_input_input(input, root)?
   47         -
    }
   48         -
    Ok(::aws_smithy_types::body::SdkBody::from(out))
   49         -
}
   50         -
   51         -
#[allow(unused_mut)]
   52         -
pub fn de_nested_xml_map_with_xml_name(
   53         -
    inp: &[u8],
   54         -
    mut builder: crate::operation::nested_xml_map_with_xml_name::builders::NestedXmlMapWithXmlNameOutputBuilder,
   55         -
) -> Result<crate::operation::nested_xml_map_with_xml_name::builders::NestedXmlMapWithXmlNameOutputBuilder, ::aws_smithy_xml::decode::XmlDecodeError>
   56         -
{
   57         -
    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
   58         -
   59         -
    #[allow(unused_mut)]
   60         -
    let mut decoder = doc.root_element()?;
   61         -
    #[allow(unused_variables)]
   62         -
    let start_el = decoder.start_el();
   63         -
    if !start_el.matches("NestedXmlMapWithXmlNameInputOutput") {
   64         -
        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
   65         -
            "encountered invalid XML root: expected NestedXmlMapWithXmlNameInputOutput but got {:?}. This is likely a bug in the SDK.",
   66         -
            start_el
   67         -
        )));
   68         -
    }
   69         -
    while let Some(mut tag) = decoder.next_tag() {
   70         -
        match tag.start_el() {
   71         -
            s if s.matches("nestedXmlMapWithXmlNameMap") /* nestedXmlMapWithXmlNameMap aws.protocoltests.restxml.synthetic#NestedXmlMapWithXmlNameOutput$nestedXmlMapWithXmlNameMap */ =>  {
   72         -
                let var_1 =
   73         -
                    Some(
   74         -
                        crate::protocol_serde::shape_nested_xml_map_with_xml_name_map::de_nested_xml_map_with_xml_name_map(&mut tag)
   75         -
                        ?
   76         -
                    )
   77         -
                ;
   78         -
                builder = builder.set_nested_xml_map_with_xml_name_map(var_1);
   79         -
            }
   80         -
            ,
   81         -
            _ => {}
   82         -
        }
   83         -
    }
   84         -
    Ok(builder)
   85         -
}

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde/shape_nested_xml_map_with_xml_name_inner_map.rs

@@ -1,0 +54,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
pub fn de_nested_xml_map_with_xml_name_inner_map(
    3         -
    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
    4         -
) -> Result<::std::collections::HashMap<::std::string::String, ::std::string::String>, ::aws_smithy_xml::decode::XmlDecodeError> {
    5         -
    let mut out = ::std::collections::HashMap::new();
    6         -
    while let Some(mut tag) = decoder.next_tag() {
    7         -
        match tag.start_el() {
    8         -
            s if s.matches("entry") => {
    9         -
                crate::protocol_serde::shape_nested_xml_map_with_xml_name_inner_map::de_nested_xml_map_with_xml_name_inner_map_entry(
   10         -
                    &mut tag, &mut out,
   11         -
                )?;
   12         -
            }
   13         -
            _ => {}
   14         -
        }
   15         -
    }
   16         -
    Ok(out)
   17         -
}
   18         -
   19         -
pub fn de_nested_xml_map_with_xml_name_inner_map_entry(
   20         -
    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
   21         -
    out: &mut ::std::collections::HashMap<::std::string::String, ::std::string::String>,
   22         -
) -> Result<(), ::aws_smithy_xml::decode::XmlDecodeError> {
   23         -
    let mut k: Option<::std::string::String> = None;
   24         -
    let mut v: Option<::std::string::String> = None;
   25         -
    while let Some(mut tag) = decoder.next_tag() {
   26         -
        match tag.start_el() {
   27         -
            s if s.matches("InnerKey") /* key aws.protocoltests.restxml#NestedXmlMapWithXmlNameInnerMap$key */ =>  {
   28         -
                k = Some(
   29         -
                    Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
   30         -
                        ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
   31         -
                        .into()
   32         -
                    )
   33         -
                    ?
   34         -
                )
   35         -
            }
   36         -
            ,
   37         -
            s if s.matches("InnerValue") /* value aws.protocoltests.restxml#NestedXmlMapWithXmlNameInnerMap$value */ =>  {
   38         -
                v = Some(
   39         -
                    Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
   40         -
                        ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
   41         -
                        .into()
   42         -
                    )
   43         -
                    ?
   44         -
                )
   45         -
            }
   46         -
            ,
   47         -
            _ => {}
   48         -
        }
   49         -
    }
   50         -
    let k = k.ok_or_else(|| ::aws_smithy_xml::decode::XmlDecodeError::custom("missing key map entry"))?;
   51         -
    let v = v.ok_or_else(|| ::aws_smithy_xml::decode::XmlDecodeError::custom("missing value map entry"))?;
   52         -
    out.insert(k, v);
   53         -
    Ok(())
   54         -
}

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde/shape_nested_xml_map_with_xml_name_input.rs

@@ -1,0 +34,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
pub fn ser_nested_xml_map_with_xml_name_input_input_input(
    3         -
    input: &crate::operation::nested_xml_map_with_xml_name::NestedXmlMapWithXmlNameInput,
    4         -
    writer: ::aws_smithy_xml::encode::ElWriter,
    5         -
) -> Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    6         -
    #[allow(unused_mut)]
    7         -
    let mut scope = writer.finish();
    8         -
    if let Some(var_1) = &input.nested_xml_map_with_xml_name_map {
    9         -
        let mut inner_writer = scope.start_el("nestedXmlMapWithXmlNameMap").finish();
   10         -
        for (key_2, value_3) in var_1 {
   11         -
            let mut entry = inner_writer.start_el("entry").finish();
   12         -
            {
   13         -
                let mut inner_writer = entry.start_el("OuterKey").finish();
   14         -
                inner_writer.data(key_2.as_str());
   15         -
            }
   16         -
            {
   17         -
                let mut inner_writer = entry.start_el("value").finish();
   18         -
                for (key_4, value_5) in value_3 {
   19         -
                    let mut entry = inner_writer.start_el("entry").finish();
   20         -
                    {
   21         -
                        let mut inner_writer = entry.start_el("InnerKey").finish();
   22         -
                        inner_writer.data(key_4.as_str());
   23         -
                    }
   24         -
                    {
   25         -
                        let mut inner_writer = entry.start_el("InnerValue").finish();
   26         -
                        inner_writer.data(value_5.as_str());
   27         -
                    }
   28         -
                }
   29         -
            }
   30         -
        }
   31         -
    }
   32         -
    scope.finish();
   33         -
    Ok(())
   34         -
}

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde/shape_nested_xml_map_with_xml_name_map.rs

@@ -1,0 +52,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
pub fn de_nested_xml_map_with_xml_name_map(
    3         -
    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
    4         -
) -> Result<
    5         -
    ::std::collections::HashMap<::std::string::String, ::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    6         -
    ::aws_smithy_xml::decode::XmlDecodeError,
    7         -
> {
    8         -
    let mut out = ::std::collections::HashMap::new();
    9         -
    while let Some(mut tag) = decoder.next_tag() {
   10         -
        match tag.start_el() {
   11         -
            s if s.matches("entry") => {
   12         -
                crate::protocol_serde::shape_nested_xml_map_with_xml_name_map::de_nested_xml_map_with_xml_name_map_entry(&mut tag, &mut out)?;
   13         -
            }
   14         -
            _ => {}
   15         -
        }
   16         -
    }
   17         -
    Ok(out)
   18         -
}
   19         -
   20         -
pub fn de_nested_xml_map_with_xml_name_map_entry(
   21         -
    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
   22         -
    out: &mut ::std::collections::HashMap<::std::string::String, ::std::collections::HashMap<::std::string::String, ::std::string::String>>,
   23         -
) -> Result<(), ::aws_smithy_xml::decode::XmlDecodeError> {
   24         -
    let mut k: Option<::std::string::String> = None;
   25         -
    let mut v: Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> = None;
   26         -
    while let Some(mut tag) = decoder.next_tag() {
   27         -
        match tag.start_el() {
   28         -
            s if s.matches("OuterKey") /* key aws.protocoltests.restxml#NestedXmlMapWithXmlNameMap$key */ =>  {
   29         -
                k = Some(
   30         -
                    Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
   31         -
                        ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
   32         -
                        .into()
   33         -
                    )
   34         -
                    ?
   35         -
                )
   36         -
            }
   37         -
            ,
   38         -
            s if s.matches("value") /* value aws.protocoltests.restxml#NestedXmlMapWithXmlNameMap$value */ =>  {
   39         -
                v = Some(
   40         -
                    crate::protocol_serde::shape_nested_xml_map_with_xml_name_inner_map::de_nested_xml_map_with_xml_name_inner_map(&mut tag)
   41         -
                    ?
   42         -
                )
   43         -
            }
   44         -
            ,
   45         -
            _ => {}
   46         -
        }
   47         -
    }
   48         -
    let k = k.ok_or_else(|| ::aws_smithy_xml::decode::XmlDecodeError::custom("missing key map entry"))?;
   49         -
    let v = v.ok_or_else(|| ::aws_smithy_xml::decode::XmlDecodeError::custom("missing value map entry"))?;
   50         -
    out.insert(k, v);
   51         -
    Ok(())
   52         -
}

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde/shape_null_and_empty_headers_client.rs

@@ -27,27 +96,97 @@
   47     47   
        output.build()
   48     48   
    })
   49     49   
}
   50     50   
   51     51   
pub fn ser_null_and_empty_headers_client_headers(
   52     52   
    input: &crate::operation::null_and_empty_headers_client::NullAndEmptyHeadersClientInput,
   53     53   
    mut builder: ::http::request::Builder,
   54     54   
) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
   55     55   
    if let ::std::option::Option::Some(inner_1) = &input.a {
   56     56   
        let formatted_2 = inner_1.as_str();
   57         -
        let header_value = formatted_2;
   58         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   59         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
   60         -
                "a",
   61         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
   62         -
            )
   63         -
        })?;
   64         -
        builder = builder.header("X-A", header_value);
          57  +
        if !formatted_2.is_empty() {
          58  +
            let header_value = formatted_2;
          59  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
          60  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
          61  +
                    "a",
          62  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
          63  +
                )
          64  +
            })?;
          65  +
            builder = builder.header("X-A", header_value);
          66  +
        }
   65     67   
    }
   66     68   
    if let ::std::option::Option::Some(inner_3) = &input.b {
   67     69   
        let formatted_4 = inner_3.as_str();
   68         -
        let header_value = formatted_4;
   69         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   70         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
   71         -
                "b",
   72         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
   73         -
            )
   74         -
        })?;
   75         -
        builder = builder.header("X-B", header_value);
          70  +
        if !formatted_4.is_empty() {
          71  +
            let header_value = formatted_4;
          72  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
          73  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
          74  +
                    "b",
          75  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
          76  +
                )
          77  +
            })?;
          78  +
            builder = builder.header("X-B", header_value);
          79  +
        }
   76     80   
    }
   77     81   
    if let ::std::option::Option::Some(inner_5) = &input.c {
   78         -
        // Empty vec in header is serialized as an empty string
   79         -
        if inner_5.is_empty() {
   80         -
            builder = builder.header("X-C", "");
   81         -
        } else {
   82         -
            for inner_6 in inner_5 {
   83         -
                let formatted_7 = ::aws_smithy_http::header::quote_header_value(inner_6.as_str());
          82  +
        for inner_6 in inner_5 {
          83  +
            let formatted_7 = ::aws_smithy_http::header::quote_header_value(inner_6.as_str());
          84  +
            if !formatted_7.is_empty() {
   84     85   
                let header_value = formatted_7;
   85     86   
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   86     87   
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
   87     88   
                        "c",
   88     89   
                        format!("`{}` cannot be used as a header value: {}", &header_value, err),
   89     90   
                    )
   90     91   
                })?;
   91     92   
                builder = builder.header("X-C", header_value);
   92     93   
            }
   93     94   
        }

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde/shape_null_and_empty_headers_server.rs

@@ -27,27 +96,97 @@
   47     47   
        output.build()
   48     48   
    })
   49     49   
}
   50     50   
   51     51   
pub fn ser_null_and_empty_headers_server_headers(
   52     52   
    input: &crate::operation::null_and_empty_headers_server::NullAndEmptyHeadersServerInput,
   53     53   
    mut builder: ::http::request::Builder,
   54     54   
) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
   55     55   
    if let ::std::option::Option::Some(inner_1) = &input.a {
   56     56   
        let formatted_2 = inner_1.as_str();
   57         -
        let header_value = formatted_2;
   58         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   59         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
   60         -
                "a",
   61         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
   62         -
            )
   63         -
        })?;
   64         -
        builder = builder.header("X-A", header_value);
          57  +
        if !formatted_2.is_empty() {
          58  +
            let header_value = formatted_2;
          59  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
          60  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
          61  +
                    "a",
          62  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
          63  +
                )
          64  +
            })?;
          65  +
            builder = builder.header("X-A", header_value);
          66  +
        }
   65     67   
    }
   66     68   
    if let ::std::option::Option::Some(inner_3) = &input.b {
   67     69   
        let formatted_4 = inner_3.as_str();
   68         -
        let header_value = formatted_4;
   69         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   70         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
   71         -
                "b",
   72         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
   73         -
            )
   74         -
        })?;
   75         -
        builder = builder.header("X-B", header_value);
          70  +
        if !formatted_4.is_empty() {
          71  +
            let header_value = formatted_4;
          72  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
          73  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
          74  +
                    "b",
          75  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
          76  +
                )
          77  +
            })?;
          78  +
            builder = builder.header("X-B", header_value);
          79  +
        }
   76     80   
    }
   77     81   
    if let ::std::option::Option::Some(inner_5) = &input.c {
   78         -
        // Empty vec in header is serialized as an empty string
   79         -
        if inner_5.is_empty() {
   80         -
            builder = builder.header("X-C", "");
   81         -
        } else {
   82         -
            for inner_6 in inner_5 {
   83         -
                let formatted_7 = ::aws_smithy_http::header::quote_header_value(inner_6.as_str());
          82  +
        for inner_6 in inner_5 {
          83  +
            let formatted_7 = ::aws_smithy_http::header::quote_header_value(inner_6.as_str());
          84  +
            if !formatted_7.is_empty() {
   84     85   
                let header_value = formatted_7;
   85     86   
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   86     87   
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
   87     88   
                        "c",
   88     89   
                        format!("`{}` cannot be used as a header value: {}", &header_value, err),
   89     90   
                    )
   90     91   
                })?;
   91     92   
                builder = builder.header("X-C", header_value);
   92     93   
            }
   93     94   
        }

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde/shape_put_with_content_encoding.rs

@@ -10,10 +63,65 @@
   30     30   
        output.build()
   31     31   
    })
   32     32   
}
   33     33   
   34     34   
pub fn ser_put_with_content_encoding_headers(
   35     35   
    input: &crate::operation::put_with_content_encoding::PutWithContentEncodingInput,
   36     36   
    mut builder: ::http::request::Builder,
   37     37   
) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
   38     38   
    if let ::std::option::Option::Some(inner_1) = &input.encoding {
   39     39   
        let formatted_2 = inner_1.as_str();
   40         -
        let header_value = formatted_2;
   41         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   42         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
   43         -
                "encoding",
   44         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
   45         -
            )
   46         -
        })?;
   47         -
        builder = builder.header("Content-Encoding", header_value);
          40  +
        if !formatted_2.is_empty() {
          41  +
            let header_value = formatted_2;
          42  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
          43  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
          44  +
                    "encoding",
          45  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
          46  +
                )
          47  +
            })?;
          48  +
            builder = builder.header("Content-Encoding", header_value);
          49  +
        }
   48     50   
    }
   49     51   
    Ok(builder)
   50     52   
}
   51     53   
   52     54   
pub fn ser_put_with_content_encoding_op_input(
   53     55   
    input: &crate::operation::put_with_content_encoding::PutWithContentEncodingInput,
   54     56   
) -> Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
   55     57   
    let mut out = String::new();
   56     58   
    {
   57     59   
        let mut writer = ::aws_smithy_xml::encode::XmlWriter::new(&mut out);

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde/shape_simple_scalar_properties.rs

@@ -17,17 +84,86 @@
   37     37   
        output.build()
   38     38   
    })
   39     39   
}
   40     40   
   41     41   
pub fn ser_simple_scalar_properties_headers(
   42     42   
    input: &crate::operation::simple_scalar_properties::SimpleScalarPropertiesInput,
   43     43   
    mut builder: ::http::request::Builder,
   44     44   
) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
   45     45   
    if let ::std::option::Option::Some(inner_1) = &input.foo {
   46     46   
        let formatted_2 = inner_1.as_str();
   47         -
        let header_value = formatted_2;
   48         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   49         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
   50         -
                "foo",
   51         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
   52         -
            )
   53         -
        })?;
   54         -
        builder = builder.header("X-Foo", header_value);
          47  +
        if !formatted_2.is_empty() {
          48  +
            let header_value = formatted_2;
          49  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
          50  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
          51  +
                    "foo",
          52  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
          53  +
                )
          54  +
            })?;
          55  +
            builder = builder.header("X-Foo", header_value);
          56  +
        }
   55     57   
    }
   56     58   
    Ok(builder)
   57     59   
}
   58     60   
   59     61   
pub fn ser_simple_scalar_properties_op_input(
   60     62   
    input: &crate::operation::simple_scalar_properties::SimpleScalarPropertiesInput,
   61     63   
) -> Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
   62     64   
    let mut out = String::new();
   63     65   
    {
   64     66   
        let mut writer = ::aws_smithy_xml::encode::XmlWriter::new(&mut out);

tmp-codegen-diff/codegen-client-test/rest_xml/rust-client-codegen/src/protocol_serde/shape_timestamp_format_headers.rs

@@ -59,59 +165,179 @@
   79     79   
        output.build()
   80     80   
    })
   81     81   
}
   82     82   
   83     83   
pub fn ser_timestamp_format_headers_headers(
   84     84   
    input: &crate::operation::timestamp_format_headers::TimestampFormatHeadersInput,
   85     85   
    mut builder: ::http::request::Builder,
   86     86   
) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
   87     87   
    if let ::std::option::Option::Some(inner_1) = &input.member_epoch_seconds {
   88     88   
        let formatted_2 = inner_1.fmt(::aws_smithy_types::date_time::Format::EpochSeconds)?;
   89         -
        let header_value = formatted_2;
   90         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   91         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
   92         -
                "member_epoch_seconds",
   93         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
   94         -
            )
   95         -
        })?;
   96         -
        builder = builder.header("X-memberEpochSeconds", header_value);
          89  +
        if !formatted_2.is_empty() {
          90  +
            let header_value = formatted_2;
          91  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
          92  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
          93  +
                    "member_epoch_seconds",
          94  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
          95  +
                )
          96  +
            })?;
          97  +
            builder = builder.header("X-memberEpochSeconds", header_value);
          98  +
        }
   97     99   
    }
   98    100   
    if let ::std::option::Option::Some(inner_3) = &input.member_http_date {
   99    101   
        let formatted_4 = inner_3.fmt(::aws_smithy_types::date_time::Format::HttpDate)?;
  100         -
        let header_value = formatted_4;
  101         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  102         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  103         -
                "member_http_date",
  104         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  105         -
            )
  106         -
        })?;
  107         -
        builder = builder.header("X-memberHttpDate", header_value);
         102  +
        if !formatted_4.is_empty() {
         103  +
            let header_value = formatted_4;
         104  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         105  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         106  +
                    "member_http_date",
         107  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         108  +
                )
         109  +
            })?;
         110  +
            builder = builder.header("X-memberHttpDate", header_value);
         111  +
        }
  108    112   
    }
  109    113   
    if let ::std::option::Option::Some(inner_5) = &input.member_date_time {
  110    114   
        let formatted_6 = inner_5.fmt(::aws_smithy_types::date_time::Format::DateTime)?;
  111         -
        let header_value = formatted_6;
  112         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  113         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  114         -
                "member_date_time",
  115         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  116         -
            )
  117         -
        })?;
  118         -
        builder = builder.header("X-memberDateTime", header_value);
         115  +
        if !formatted_6.is_empty() {
         116  +
            let header_value = formatted_6;
         117  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         118  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         119  +
                    "member_date_time",
         120  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         121  +
                )
         122  +
            })?;
         123  +
            builder = builder.header("X-memberDateTime", header_value);
         124  +
        }
  119    125   
    }
  120    126   
    if let ::std::option::Option::Some(inner_7) = &input.default_format {
  121    127   
        let formatted_8 = inner_7.fmt(::aws_smithy_types::date_time::Format::HttpDate)?;
  122         -
        let header_value = formatted_8;
  123         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  124         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  125         -
                "default_format",
  126         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  127         -
            )
  128         -
        })?;
  129         -
        builder = builder.header("X-defaultFormat", header_value);
         128  +
        if !formatted_8.is_empty() {
         129  +
            let header_value = formatted_8;
         130  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         131  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         132  +
                    "default_format",
         133  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         134  +
                )
         135  +
            })?;
         136  +
            builder = builder.header("X-defaultFormat", header_value);
         137  +
        }
  130    138   
    }
  131    139   
    if let ::std::option::Option::Some(inner_9) = &input.target_epoch_seconds {
  132    140   
        let formatted_10 = inner_9.fmt(::aws_smithy_types::date_time::Format::EpochSeconds)?;
  133         -
        let header_value = formatted_10;
  134         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  135         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  136         -
                "target_epoch_seconds",
  137         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  138         -
            )
  139         -
        })?;
  140         -
        builder = builder.header("X-targetEpochSeconds", header_value);
         141  +
        if !formatted_10.is_empty() {
         142  +
            let header_value = formatted_10;
         143  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         144  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         145  +
                    "target_epoch_seconds",
         146  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         147  +
                )
         148  +
            })?;
         149  +
            builder = builder.header("X-targetEpochSeconds", header_value);
         150  +
        }
  141    151   
    }
  142    152   
    if let ::std::option::Option::Some(inner_11) = &input.target_http_date {
  143    153   
        let formatted_12 = inner_11.fmt(::aws_smithy_types::date_time::Format::HttpDate)?;
  144         -
        let header_value = formatted_12;
  145         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  146         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  147         -
                "target_http_date",
  148         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  149         -
            )
  150         -
        })?;
  151         -
        builder = builder.header("X-targetHttpDate", header_value);
         154  +
        if !formatted_12.is_empty() {
         155  +
            let header_value = formatted_12;
         156  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         157  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         158  +
                    "target_http_date",
         159  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         160  +
                )
         161  +
            })?;
         162  +
            builder = builder.header("X-targetHttpDate", header_value);
         163  +
        }
  152    164   
    }
  153    165   
    if let ::std::option::Option::Some(inner_13) = &input.target_date_time {
  154    166   
        let formatted_14 = inner_13.fmt(::aws_smithy_types::date_time::Format::DateTime)?;
  155         -
        let header_value = formatted_14;
  156         -
        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  157         -
            ::aws_smithy_types::error::operation::BuildError::invalid_field(
  158         -
                "target_date_time",
  159         -
                format!("`{}` cannot be used as a header value: {}", &header_value, err),
  160         -
            )
  161         -
        })?;
  162         -
        builder = builder.header("X-targetDateTime", header_value);
         167  +
        if !formatted_14.is_empty() {
         168  +
            let header_value = formatted_14;
         169  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         170  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         171  +
                    "target_date_time",
         172  +
                    format!("`{}` cannot be used as a header value: {}", &header_value, err),
         173  +
                )
         174  +
            })?;
         175  +
            builder = builder.header("X-targetDateTime", header_value);
         176  +
        }
  163    177   
    }
  164    178   
    Ok(builder)
  165    179   
}