Implement Targets#SetHeader
This commit is contained in:
@@ -56,3 +56,10 @@ func (t Targets) Shuffle(seed int64) {
|
|||||||
t[i], t[rnd] = t[rnd], t[i]
|
t[i], t[rnd] = t[rnd], t[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetHeader sets the passed request header in all Targets
|
||||||
|
func (t Targets) SetHeader(header http.Header) {
|
||||||
|
for _, target := range t {
|
||||||
|
target.Header = header
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,3 +52,14 @@ func TestShuffle(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Fatal("Targets were not shuffled correctly")
|
t.Fatal("Targets were not shuffled correctly")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSetHeader(t *testing.T) {
|
||||||
|
targets, _ := NewTargets([]string{"GET http://lolcathost:9999/", "HEAD http://lolcathost:9999/"})
|
||||||
|
want := "lolcathost.com"
|
||||||
|
targets.SetHeader(http.Header{"Host": []string{want}})
|
||||||
|
for _, target := range targets {
|
||||||
|
if got := target.Header.Get("Host"); got != want {
|
||||||
|
t.Errorf("Want: %s, Got: %s", want, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user