Skip to content

Commit 10884d5

Browse files
committed
Merge branch 'buzztaiki-no_redirect' into mergetest
- Do not allow auto-redirect. Fixes #29.
2 parents c08ca3a + cb9490d commit 10884d5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

aws-es-proxy.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ func newProxy(args ...interface{}) *proxy {
9393
}
9494
}
9595

96+
var client = &http.Client{
97+
CheckRedirect: noRedirect,
98+
}
99+
100+
func noRedirect(req *http.Request, via []*http.Request) error {
101+
return http.ErrUseLastResponse
102+
}
103+
96104
func (p *proxy) parseEndpoint() error {
97105
var (
98106
link *url.URL
@@ -235,7 +243,7 @@ func (p *proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
235243
signer.Sign(req, payload, p.service, p.region, time.Now())
236244
}
237245

238-
resp, err := http.DefaultClient.Do(req)
246+
resp, err := client.Do(req)
239247
if err != nil {
240248
logrus.Errorln(err)
241249
http.Error(w, err.Error(), http.StatusBadRequest)

0 commit comments

Comments
 (0)