darklynx / request-baskets

HTTP requests collector to test webhooks, notifications, REST clients and more ...
https://rbaskets.in
MIT License
351 stars 51 forks source link

Host header is missing from the Headers section #61

Open sashee opened 4 years ago

sashee commented 4 years ago

When I send a request with a different Host header then the request is logged successfully but the Host is missing.

curl -H "Host: example.com" https://rbaskets.in/3vgdn65

Shows:

image

Testing with webhooks.site the host header is listed:

image

This prevents debugging host-related issues.

darklynx commented 4 years ago

This is a result of Go-lang net/http library behavior, see https://golang.org/src/net/http/request.go#L159

// For incoming requests, the Host header is promoted to the // Request.Host field and removed from the Header map.

:(

On the other hand the Request.Host field does not contain a host header only instead it is defined as following: https://golang.org/src/net/http/request.go#L221

TL;DR: if Host-header is not defined, Request.Host will contain a host part of the URL the request was made to :(

In order to expose Host-header properly I need to find out how to either get an access to the raw HTTP-request, or how to figure out that Request.Host field contains the host header and not the part of URL