mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
Fixed tests
This commit is contained in:
+2
-6
@@ -99,7 +99,7 @@ func (o *HTTPOutput) Write(data []byte) (n int, err error) {
|
||||
buf := make([]byte, len(data))
|
||||
copy(buf, data)
|
||||
|
||||
go o.sendRequest(buf)
|
||||
o.buf <- buf
|
||||
|
||||
return len(data), nil
|
||||
}
|
||||
@@ -115,11 +115,7 @@ func (o *HTTPOutput) sendRequest(client *http.Client, data []byte) {
|
||||
if len(o.methods) > 0 && !o.methods.Contains(request.Method) {
|
||||
return
|
||||
}
|
||||
|
||||
client := &http.Client{
|
||||
CheckRedirect: customCheckRedirect,
|
||||
}
|
||||
|
||||
|
||||
// Change HOST of original request
|
||||
URL := o.address + request.URL.Path + "?" + request.URL.RawQuery
|
||||
|
||||
|
||||
+3
-4
@@ -28,9 +28,7 @@ func TestHTTPOutput(t *testing.T) {
|
||||
input := NewTestInput()
|
||||
|
||||
headers := HTTPHeaders{HTTPHeader{"User-Agent", "Gor"}}
|
||||
|
||||
methods := HTTPMethods{"GET", "PUT", "POST"}
|
||||
output := NewHTTPOutput("127.0.0.1:50003", headers, methods, "")
|
||||
|
||||
listener := startHTTP(func(req *http.Request) {
|
||||
if req.Header.Get("User-Agent") != "Gor" {
|
||||
@@ -44,7 +42,7 @@ func TestHTTPOutput(t *testing.T) {
|
||||
wg.Done()
|
||||
})
|
||||
|
||||
output := NewHTTPOutput(listener.Addr().String(), headers, "")
|
||||
output := NewHTTPOutput(listener.Addr().String(), headers, methods, "")
|
||||
|
||||
Plugins.Inputs = []io.Reader{input}
|
||||
Plugins.Outputs = []io.Writer{output}
|
||||
@@ -70,13 +68,14 @@ func BenchmarkHTTPOutput(b *testing.B) {
|
||||
input := NewTestInput()
|
||||
|
||||
headers := HTTPHeaders{HTTPHeader{"User-Agent", "Gor"}}
|
||||
methods := HTTPMethods{"GET", "PUT", "POST"}
|
||||
|
||||
listener := startHTTP(func(req *http.Request) {
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
wg.Done()
|
||||
})
|
||||
|
||||
output := NewHTTPOutput(listener.Addr().String(), headers, "")
|
||||
output := NewHTTPOutput(listener.Addr().String(), headers, methods, "")
|
||||
|
||||
Plugins.Inputs = []io.Reader{input}
|
||||
Plugins.Outputs = []io.Writer{output}
|
||||
|
||||
Reference in New Issue
Block a user