aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-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