Closed danthegoodman1 closed 9 months ago
c.Request().Header.Get("Host")
is not something that Echo touches. I assume that Go standard library HTTP server does not set Host into header as that same thing is in Request.Host
field
I guess we could add middleware to actually set it back, but it seems incorrect (whether at the go level or echo) that it wouldn’t be set properly?
If you search Golang github you probably find answer there. I doubt you are first person to ask the same question. Also Request.Host
field has comments. Probably in some situations you can do request without host header (probably HTTP/1.0
) and it is deduced from the request url.
https://github.com/golang/go/issues/14239 just "won't fix" weird...
probably some optimization etc. As Request.Host
is always filled there is no point to populate Request.Headers
map with that value and use additional memory. Also if it is not guaranteed to exists as HTTP/1.0
does not require that header.
I am closing this issue as I believe there nothing to fix/change from Echo side.
Issue Description
ctx.Request().Header.Get("host")
is always a blank string (at least testing against my local server). I seeChecklist
Expected behaviour
It's the value of the
Host
headerActual behaviour
You can see that curl is setting the host header properly.
note the newline before indicating it's a blank string
Steps to reproduce
curl localhost:8080
Working code to debug
Version/commit
github.com/labstack/echo/v4 v4.9.1