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 | }
|