You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
golang's net/http library seems to ignore a Host header and only uses the value set in request struct or extracts it from url.Host. In order to be able to set a flag like -header="Host: foo.bar" it's necessary to treat that that header different than others.
This works for me:
diff --git a/lib/targets.go b/lib/targets.go
index 9b9739a..b3d70b2 100644
--- a/lib/targets.go+++ b/lib/targets.go@@ -63,8 +63,12 @@ func (t Targets) SetHeader(header http.Header) {
for _, target := range t {
target.Header = make(http.Header, len(header))
for k, vs := range header {
- target.Header[k] = make([]string, len(vs))- copy(target.Header[k], vs)+ if k == "Host" {+ target.Host = vs[0]+ } else {+ target.Header[k] = make([]string, len(vs))+ copy(target.Header[k], vs)+ }
}
}
}
No idea why the copy of the headers is necessary, it might be necessary for the Host field as well then.
The text was updated successfully, but these errors were encountered:
I agree that this is very useful in certain situations. Please open a PR with your change set and test it if you want brevity on this issue. Otherwise I can do it too, but I can't promise it will be very soon.
The copy of the headers is necessary because the net/http pkg mutates the headers underneath for various reasons (like setting auth headers from the url info, the host header, etc). You can check out this old issue for further reference: #30
golang's net/http library seems to ignore a Host header and only uses the value set in request struct or extracts it from
url.Host
. In order to be able to set a flag like-header="Host: foo.bar"
it's necessary to treat that that header different than others.This works for me:
No idea why the copy of the headers is necessary, it might be necessary for the Host field as well then.
The text was updated successfully, but these errors were encountered: