mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
Fix #15
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package replay
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
@@ -37,9 +38,19 @@ func NewRequestFactory() (factory *RequestFactory) {
|
||||
return
|
||||
}
|
||||
|
||||
// Allow only 2 redirects https://github.com/buger/gor/pull/15
|
||||
func customCheckRedirect(req *http.Request, via []*http.Request) error {
|
||||
if len(via) >= 2 {
|
||||
return errors.New("stopped after 2 redirects")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Forward http request to given host
|
||||
func (f *RequestFactory) sendRequest(host *ForwardHost, request *http.Request) {
|
||||
client := &http.Client{}
|
||||
client := &http.Client{
|
||||
CheckRedirect: customCheckRedirect,
|
||||
}
|
||||
|
||||
// Change HOST of original request
|
||||
URL := host.Url + request.URL.Path + "?" + request.URL.RawQuery
|
||||
|
||||
Reference in New Issue
Block a user