Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions lambda-http/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ impl LambdaResponse {
body,
is_base64_encoded,
status_code: status_code as i64,
headers: headers.clone(),
// explicitly empty, as API gateway does not properly merge headers and
// multi-value-headers, resulting in duplicate headers
headers: HeaderMap::new(),
multi_value_headers: headers,
}),
#[cfg(feature = "apigw_http")]
Expand All @@ -91,7 +93,9 @@ impl LambdaResponse {
is_base64_encoded,
status_code: status_code as i64,
cookies,
headers: headers.clone(),
// explicitly empty, as API gateway does not properly merge headers and
// multi-value-headers, resulting in duplicate headers
headers: HeaderMap::new(),
multi_value_headers: headers,
})
}
Expand All @@ -100,7 +104,9 @@ impl LambdaResponse {
body,
status_code: status_code as i64,
is_base64_encoded,
headers: headers.clone(),
// explicitly empty, as API gateway does not properly merge headers and
// multi-value-headers, resulting in duplicate headers
headers: HeaderMap::new(),
multi_value_headers: headers,
status_description: Some(format!(
"{} {}",
Expand All @@ -113,7 +119,9 @@ impl LambdaResponse {
body,
is_base64_encoded,
status_code: status_code as i64,
headers: headers.clone(),
// explicitly empty, as API gateway does not properly merge headers and
// multi-value-headers, resulting in duplicate headers
headers: HeaderMap::new(),
multi_value_headers: headers,
}),
#[cfg(feature = "pass_through")]
Expand Down Expand Up @@ -465,7 +473,7 @@ mod tests {
let json = serde_json::to_string(&response).expect("failed to serialize to json");
assert_eq!(
json,
r#"{"statusCode":200,"headers":{"content-encoding":"gzip"},"multiValueHeaders":{"content-encoding":["gzip"]},"body":"MDAwMDAw","isBase64Encoded":true,"cookies":[]}"#
r#"{"statusCode":200,"headers":{},"multiValueHeaders":{"content-encoding":["gzip"]},"body":"MDAwMDAw","isBase64Encoded":true,"cookies":[]}"#
)
}

Expand All @@ -483,7 +491,7 @@ mod tests {
let json = serde_json::to_string(&response).expect("failed to serialize to json");
assert_eq!(
json,
r#"{"statusCode":200,"headers":{"content-type":"application/json"},"multiValueHeaders":{"content-type":["application/json"]},"body":"000000","isBase64Encoded":false,"cookies":[]}"#
r#"{"statusCode":200,"headers":{},"multiValueHeaders":{"content-type":["application/json"]},"body":"000000","isBase64Encoded":false,"cookies":[]}"#
)
}

Expand All @@ -501,7 +509,7 @@ mod tests {
let json = serde_json::to_string(&response).expect("failed to serialize to json");
assert_eq!(
json,
r#"{"statusCode":200,"headers":{"content-type":"application/json; charset=utf-16"},"multiValueHeaders":{"content-type":["application/json; charset=utf-16"]},"body":"〰〰〰","isBase64Encoded":false,"cookies":[]}"#
r#"{"statusCode":200,"headers":{},"multiValueHeaders":{"content-type":["application/json; charset=utf-16"]},"body":"〰〰〰","isBase64Encoded":false,"cookies":[]}"#
)
}

Expand All @@ -519,7 +527,7 @@ mod tests {
let json = serde_json::to_string(&response).expect("failed to serialize to json");
assert_eq!(
json,
r#"{"statusCode":200,"headers":{"content-type":"application/graphql-response+json; charset=utf-16"},"multiValueHeaders":{"content-type":["application/graphql-response+json; charset=utf-16"]},"body":"〰〰〰","isBase64Encoded":false,"cookies":[]}"#
r#"{"statusCode":200,"headers":{},"multiValueHeaders":{"content-type":["application/graphql-response+json; charset=utf-16"]},"body":"〰〰〰","isBase64Encoded":false,"cookies":[]}"#
)
}

Expand Down Expand Up @@ -553,7 +561,7 @@ mod tests {
let json = serde_json::to_string(&res).expect("failed to serialize to json");
assert_eq!(
json,
r#"{"statusCode":200,"headers":{"multi":"a"},"multiValueHeaders":{"multi":["a","b"]},"isBase64Encoded":false}"#
r#"{"statusCode":200,"headers":{},"multiValueHeaders":{"multi":["a","b"]},"isBase64Encoded":false}"#
)
}

Expand Down