diff --git a/output_http.go b/output_http.go index fdc9f9a..5b308af 100644 --- a/output_http.go +++ b/output_http.go @@ -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 diff --git a/output_http_test.go b/output_http_test.go index 5733e68..55fb4fd 100644 --- a/output_http_test.go +++ b/output_http_test.go @@ -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}