You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt
+26-19Lines changed: 26 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -617,17 +617,26 @@ class HttpBindingGenerator(
617
617
)(this)
618
618
}
619
619
620
-
rustBlock("for ${loopVariable.name} in ${context.valueExpression.asRef()}") {
621
-
this.renderHeaderValue(
622
-
headerName,
623
-
loopVariable,
624
-
model.expectShape(shape.member.target),
625
-
isMultiValuedHeader =true,
626
-
timestampFormat,
627
-
renderErrorMessage,
628
-
serializeIfDefault =true,
629
-
shape.member,
630
-
)
620
+
rustTemplate(
621
+
"""
622
+
// Empty vecs in headers are serialized as the empty string
623
+
if ${context.valueExpression.asRef()}.len() == 0 {
624
+
builder = builder.header("$headerName", "");
625
+
}""",
626
+
)
627
+
rustBlock("else") {
628
+
rustBlock("for ${loopVariable.name} in ${context.valueExpression.asRef()}") {
629
+
this.renderHeaderValue(
630
+
headerName,
631
+
loopVariable,
632
+
model.expectShape(shape.member.target),
633
+
isMultiValuedHeader =true,
634
+
timestampFormat,
635
+
renderErrorMessage,
636
+
serializeIfDefault =true,
637
+
shape.member,
638
+
)
639
+
}
631
640
}
632
641
}
633
642
@@ -671,14 +680,12 @@ class HttpBindingGenerator(
671
680
val safeName = safeName("formatted")
672
681
rustTemplate(
673
682
"""
674
-
let $safeName = $formatted;
675
-
if !$safeName.is_empty() {
676
-
let header_value = $safeName;
677
-
let header_value: #{HeaderValue} = header_value.parse().map_err(|err| {
0 commit comments