Skip to content

Commit ad65665

Browse files
committed
fix: fix response headers
1 parent 27200d8 commit ad65665

File tree

6 files changed

+21
-16
lines changed

6 files changed

+21
-16
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SERVER_ADDR=127.0.0.1:8080
22
# if not set, use in-memory cache
33
# REDIS_URL=127.0.0.1:6379
44
POLL_INTERVAL=100 # in milliseconds
5-
REQUEST_TIMEOUT=10000 # in milliseconds
5+
REQUEST_TIMEOUT=30000 # in milliseconds
66
LOG_LEVEL=info # debug, info, warn, error
77
# cert file path to enable https, for example: /etc/https/mydomain.crt
88
TLS_CERT_FILE = ""

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ strip = true
1515
opt-level = 's'
1616

1717
[workspace.package]
18-
version = "1.1.5"
18+
version = "1.1.6"
1919
edition = "2021"
2020
repository = "https://github.com/ldclabs/idempotent-proxy"
2121
keywords = ["idempotent", "reverse", "proxy", "icp"]

src/idempotent-proxy-cf-worker/src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class ResponseData {
8383
if (key == 'content-type') {
8484
this.mime = value
8585
} else if (
86-
key != 'content-length' &&
86+
key != 'content-length' && key != 'transfer-encoding' &&
8787
(fi.length == 0 || fi.includes(key))
8888
) {
8989
this.headers.push([key, value])

src/idempotent-proxy-server/src/cache/mod.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,17 @@ impl ResponseData {
123123

124124
for (k, v) in headers.iter() {
125125
if let Ok(v) = v.to_str() {
126-
let k = k.as_str();
127-
if k == "content-type" {
128-
self.mime = v.to_string();
129-
} else if k != "content-length" && (filtering.is_empty() || filtering.contains(&k))
130-
{
131-
self.headers.push((k.to_string(), v.to_string()));
126+
match k.as_str() {
127+
"content-type" => {
128+
self.mime = v.to_string();
129+
}
130+
"content-length" | "transfer-encoding" => {
131+
continue;
132+
}
133+
k if filtering.is_empty() || filtering.contains(&k) => {
134+
self.headers.push((k.to_string(), v.to_string()));
135+
}
136+
_ => {}
132137
}
133138
}
134139
}

src/idempotent-proxy-server/src/handler.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use axum::{
22
body::to_bytes,
33
extract::{Request, State},
4-
response::{IntoResponse, Response},
4+
response::IntoResponse,
55
};
66
use base64::{engine::general_purpose, Engine};
77
use http::{header::AsHeaderName, HeaderMap, HeaderValue, StatusCode};
@@ -72,7 +72,7 @@ impl AppState {
7272
pub async fn proxy(
7373
State(app): State<AppState>,
7474
req: Request,
75-
) -> Result<Response, (StatusCode, String)> {
75+
) -> Result<impl IntoResponse, (StatusCode, String)> {
7676
// Access control
7777
let agent = if !app.ecdsa_pub_keys.is_empty() || !app.ed25519_pub_keys.is_empty() {
7878
let token = extract_header(req.headers(), &HEADER_PROXY_AUTHORIZATION, || {
@@ -161,7 +161,7 @@ pub async fn proxy(
161161
agent = agent,
162162
idempotency_key = idempotency_key;
163163
"");
164-
return Ok(res.into_response());
164+
return Ok(res);
165165
}
166166

167167
let res = {
@@ -201,7 +201,7 @@ pub async fn proxy(
201201
.await
202202
.map_err(bad_gateway)?;
203203

204-
Ok(rd.into_response())
204+
Ok(rd)
205205
} else {
206206
Err((status, String::from_utf8_lossy(&res_body).to_string()))
207207
}

0 commit comments

Comments
 (0)