Skip to content

Commit

Permalink
[Rust-Axum] BugFix: handling non-lowercase Header in Request/Response (
Browse files Browse the repository at this point in the history
  • Loading branch information
linxGnu authored Nov 26, 2024
1 parent ed21105 commit 19e2141
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ where
// Header parameters
let header_params = {
{{/-first}}
let header_{{{paramName}}} = headers.get(HeaderName::from_static("{{{baseName}}}"));
let header_{{{paramName}}} = headers.get(HeaderName::from_static("{{{nameInLowerCase}}}"));

let header_{{{paramName}}} = match header_{{{paramName}}} {
Some(v) => match header::IntoHeaderValue::<{{{dataType}}}>::try_from((*v).clone()) {
Expand Down Expand Up @@ -272,7 +272,7 @@ where
{
let mut response_headers = response.headers_mut().unwrap();
response_headers.insert(
HeaderName::from_static("{{{baseName}}}"),
HeaderName::from_static("{{{nameInLowerCase}}}"),
{{name}}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ where
{
// Header parameters
let header_params = {
let header_x_header = headers.get(HeaderName::from_static("X-Header"));
let header_x_header = headers.get(HeaderName::from_static("x-header"));

let header_x_header = match header_x_header {
Some(v) => match header::IntoHeaderValue::<String>::try_from((*v).clone()) {
Expand Down Expand Up @@ -1471,7 +1471,7 @@ where

{
let mut response_headers = response.headers_mut().unwrap();
response_headers.insert(HeaderName::from_static("Success-Info"), success_info);
response_headers.insert(HeaderName::from_static("success-info"), success_info);
}
if let Some(bool_header) = bool_header {
let bool_header = match header::IntoHeaderValue(bool_header).try_into() {
Expand All @@ -1486,7 +1486,7 @@ where
{
let mut response_headers = response.headers_mut().unwrap();
response_headers
.insert(HeaderName::from_static("Bool-Header"), bool_header);
.insert(HeaderName::from_static("bool-header"), bool_header);
}
}
if let Some(object_header) = object_header {
Expand All @@ -1502,7 +1502,7 @@ where
{
let mut response_headers = response.headers_mut().unwrap();
response_headers
.insert(HeaderName::from_static("Object-Header"), object_header);
.insert(HeaderName::from_static("object-header"), object_header);
}
}
let mut response = response.status(200);
Expand Down Expand Up @@ -1544,7 +1544,7 @@ where
{
let mut response_headers = response.headers_mut().unwrap();
response_headers
.insert(HeaderName::from_static("Further-Info"), further_info);
.insert(HeaderName::from_static("further-info"), further_info);
}
}
if let Some(failure_info) = failure_info {
Expand All @@ -1560,7 +1560,7 @@ where
{
let mut response_headers = response.headers_mut().unwrap();
response_headers
.insert(HeaderName::from_static("Failure-Info"), failure_info);
.insert(HeaderName::from_static("failure-info"), failure_info);
}
}
let mut response = response.status(412);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2693,7 +2693,7 @@ where
{
let mut response_headers = response.headers_mut().unwrap();
response_headers
.insert(HeaderName::from_static("X-Rate-Limit"), x_rate_limit);
.insert(HeaderName::from_static("x-rate-limit"), x_rate_limit);
}
}
if let Some(x_expires_after) = x_expires_after {
Expand All @@ -2710,7 +2710,7 @@ where
{
let mut response_headers = response.headers_mut().unwrap();
response_headers
.insert(HeaderName::from_static("X-Expires-After"), x_expires_after);
.insert(HeaderName::from_static("x-expires-after"), x_expires_after);
}
}
let mut response = response.status(200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ where

{
let mut response_headers = response.headers_mut().unwrap();
response_headers.insert(HeaderName::from_static("Set-Cookie"), set_cookie);
response_headers.insert(HeaderName::from_static("set-cookie"), set_cookie);
}
}
if let Some(x_rate_limit) = x_rate_limit {
Expand All @@ -1533,7 +1533,7 @@ where
{
let mut response_headers = response.headers_mut().unwrap();
response_headers
.insert(HeaderName::from_static("X-Rate-Limit"), x_rate_limit);
.insert(HeaderName::from_static("x-rate-limit"), x_rate_limit);
}
}
if let Some(x_expires_after) = x_expires_after {
Expand All @@ -1550,7 +1550,7 @@ where
{
let mut response_headers = response.headers_mut().unwrap();
response_headers
.insert(HeaderName::from_static("X-Expires-After"), x_expires_after);
.insert(HeaderName::from_static("x-expires-after"), x_expires_after);
}
}
let mut response = response.status(200);
Expand Down

0 comments on commit 19e2141

Please sign in to comment.