From ee9f40158e0b0fdb62a7e83d475a1ecc10a17a4b Mon Sep 17 00:00:00 2001 From: Marius Date: Tue, 11 Apr 2023 13:56:10 +0200 Subject: [PATCH] core: Add Host header to hooks event Closes https://github.com/tus/tusd/issues/935 --- pkg/handler/unrouted_handler.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/handler/unrouted_handler.go b/pkg/handler/unrouted_handler.go index e798fc1..378a18d 100644 --- a/pkg/handler/unrouted_handler.go +++ b/pkg/handler/unrouted_handler.go @@ -98,6 +98,12 @@ type HookEvent struct { } func newHookEvent(info FileInfo, r *http.Request) HookEvent { + // The Host header field is not present in the header map, see https://pkg.go.dev/net/http#Request: + // > For incoming requests, the Host header is promoted to the + // > Request.Host field and removed from the Header map. + // That's why we add it back manually. + r.Header.Set("Host", r.Host) + return HookEvent{ Upload: info, HTTPRequest: HTTPRequest{