Skip to content

armgit / hey

Public Imported from GitHub
0

HTTP load generator, ApacheBench (ab) replacement

Go

Send hostname all the way through the request as the Host header

Mat Evansabe61839a704
diff --git a/boom.go b/boom.go
index cd241cc..3bfdc3d 100644
--- a/boom.go
+++ b/boom.go
@@ -151,6 +151,7 @@ func main() {
Url: url,
Body: *flagD,
Header: header,
+ Host: serverName,
Username: username,
Password: password,
ServerName: serverName,
diff --git a/commands/boom.go b/commands/boom.go
index 0c03c8e..859d96b 100644
--- a/commands/boom.go
+++ b/commands/boom.go
@@ -33,6 +33,7 @@ type ReqOpts struct {
Method string
Url string
Header http.Header
+ Host string
Body string
Username string
Password string
@@ -45,6 +46,10 @@ type ReqOpts struct {
func (r *ReqOpts) Request() *http.Request {
req, _ := http.NewRequest(r.Method, r.Url, strings.NewReader(r.Body))
req.Header = r.Header
+
+ // update the Host value in the Request - this is used as the host header in any subsequent request
+ req.Host = r.Host
+
if r.Username != "" && r.Password != "" {
req.SetBasicAuth(r.Username, r.Password)
}