Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make -H 'Host: my-server' set Host Header on Requests #272

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions libgobuster/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type HTTPHeader struct {
type HTTPClient struct {
client *http.Client
context context.Context
host string
userAgent string
defaultUserAgent string
username string
Expand Down Expand Up @@ -87,6 +88,13 @@ func NewHTTPClient(c context.Context, opt *HTTPOptions) (*HTTPClient, error) {
if client.method == "" {
client.method = http.MethodGet
}
client.host = ""
for _, h := range opt.Headers {
if h.Name == "Host" {
client.host = h.Value
break
}
}
return &client, nil
}

Expand Down Expand Up @@ -138,6 +146,8 @@ func (client *HTTPClient) makeRequest(fullURL, host string, data io.Reader) (*ht

if host != "" {
req.Host = host
} else if client.host != "" {
req.Host = client.host
}

if client.userAgent != "" {
Expand Down