Skip to content

Commit

Permalink
Merge pull request #1068 from dfinity/paulliu/drop-host-header
Browse files Browse the repository at this point in the history
fix: drop Host header in https outcall request
  • Loading branch information
ninegua authored Jan 7, 2025
2 parents 34ec579 + 674a6e9 commit 27fa082
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 10 deletions.
1 change: 0 additions & 1 deletion motoko/send_http_post/src/send_http_post_backend/main.mo
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ actor {
//idempotency keys should be unique so we create a function that generates them.
let idempotency_key : Text = generateUUID();
let request_headers = [
{ name = "Host"; value = host # ":443" },
{ name = "User-Agent"; value = "http_post_sample" },
{ name = "Content-Type"; value = "application/json" },
{ name = "Idempotency-Key"; value = idempotency_key },
Expand Down
4 changes: 0 additions & 4 deletions rust/send_http_get/src/send_http_get_backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ async fn get_icp_usd_exchange() -> String {
// 2.2 prepare headers for the system http_request call
//Note that `HttpHeader` is declared in line 4
let request_headers = vec![
HttpHeader {
name: "Host".to_string(),
value: format!("{host}:443"),
},
HttpHeader {
name: "User-Agent".to_string(),
value: "exchange_rate_canister".to_string(),
Expand Down
6 changes: 1 addition & 5 deletions rust/send_http_post/src/send_http_post_backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ async fn send_http_post_request() -> String {
// 2.2 prepare headers for the system http_request call
//Note that `HttpHeader` is declared in line 4
let request_headers = vec![
HttpHeader {
name: "Host".to_string(),
value: format!("{host}:443"),
},
HttpHeader {
name: "User-Agent".to_string(),
value: "demo_HTTP_POST_canister".to_string(),
Expand Down Expand Up @@ -191,4 +187,4 @@ fn transform(raw: TransformArgs) -> HttpResponse {
ic_cdk::api::print(format!("Received an error from coinbase: err = {:?}", raw));
}
res
}
}

0 comments on commit 27fa082

Please sign in to comment.