aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-01-02 00:22:52 -0800
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-01-02 00:22:52 -0800
commita3a2fb1e4fa0d67f19e6679aececa6c3ad882abb (patch)
tree6f566da82b5ad78bc811fc46155873eb76a8d541
parent915dadd9d7f660d6bc251831e8f49edc5f7e7382 (diff)
downloadbun-a3a2fb1e4fa0d67f19e6679aececa6c3ad882abb.tar.gz
bun-a3a2fb1e4fa0d67f19e6679aececa6c3ad882abb.tar.zst
bun-a3a2fb1e4fa0d67f19e6679aececa6c3ad882abb.zip
Update http.zig
-rw-r--r--src/http.zig12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/http.zig b/src/http.zig
index f101b5b38..34b5dea0a 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -127,13 +127,14 @@ pub const RequestContext = struct {
}
if (protocol == null) {
- // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto
determine_protocol: {
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Upgrade-Insecure-Requests
if (this.header("Upgrade-Insecure-Requests") != null) {
protocol = "https";
break :determine_protocol;
}
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto
if (this.header("X-Forwarded-Proto")) |proto| {
if (strings.eqlComptime(proto, "https")) {
protocol = "https";
@@ -159,15 +160,16 @@ pub const RequestContext = struct {
}
}
- if (this.header("Origin")) |origin| {
- this.origin = ZigURL.parse(origin);
- return;
+ if (protocol == null) {
+ if (this.header("Origin")) |origin| {
+ this.origin = ZigURL.parse(origin);
+ return;
+ }
}
}
if (host != null or protocol != null) {
// Proxies like Caddy might only send X-Forwarded-Proto if the host matches
- // In that case,
const display_protocol = protocol orelse @as(string, "http");
var display_host = host orelse
(if (protocol != null) this.header("Host") else null) orelse