Skip to content

Commit

Permalink
chore: remove upgrade_insecure_requests header in PocketIC gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
mraszyk committed Nov 14, 2024
1 parent 03f3deb commit 639c521
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions rs/pocket_ic_server/src/state_api/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use futures::future::Shared;
use http::{
header::{
ACCEPT_RANGES, CACHE_CONTROL, CONTENT_LENGTH, CONTENT_RANGE, CONTENT_TYPE, COOKIE, DNT,
IF_MODIFIED_SINCE, IF_NONE_MATCH, RANGE, USER_AGENT,
IF_MODIFIED_SINCE, IF_NONE_MATCH, RANGE, UPGRADE_INSECURE_REQUESTS, USER_AGENT,
},
HeaderName, Method, StatusCode, Uri,
};
Expand Down Expand Up @@ -506,6 +506,7 @@ pub(crate) struct HandlerState {
backend_client: Client<HttpConnector, Body>,
resolver: DomainResolver,
replica_url: String,
is_https: bool,
}

impl HandlerState {
Expand All @@ -514,12 +515,14 @@ impl HandlerState {
backend_client: Client<HttpConnector, Body>,
resolver: DomainResolver,
replica_url: String,
is_https: bool,
) -> Self {
Self {
http_gateway_client,
backend_client,
resolver,
replica_url,
is_https,
}
}

Expand Down Expand Up @@ -614,8 +617,15 @@ async fn handler(
req.send().await
};

let mut http_response = resp.canister_response;
if !state.is_https {
http_response
.headers_mut()
.remove(UPGRADE_INSECURE_REQUESTS);
}

// Convert it into Axum response
let response = resp.canister_response.into_response();
let response = http_response.into_response();

Ok(HandlerResponse::ResponseBody(response))
}
Expand Down Expand Up @@ -968,6 +978,7 @@ impl ApiState {
backend_client,
domain_resolver,
replica_url.clone(),
http_gateway_config.https_config.is_some(),
));

let router_api_v2 = Router::new()
Expand Down

0 comments on commit 639c521

Please sign in to comment.