Skip to content

Commit 5392fe2

Browse files
committed
fix: Prevent following redirects from PHP responses
1 parent d50c174 commit 5392fe2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,12 @@ func getProxyResp(r *http.Request, contents []byte) (*http.Response, error) {
258258
gamezipRequest.Body = io.NopCloser(bytes.NewReader(contents))
259259

260260
// Make the request to the zip server.
261-
client := &http.Client{}
261+
client := &http.Client{
262+
// Don't follow redirects, let the client we've serving do it instead
263+
CheckRedirect: func(req *http.Request, via []*http.Request) error {
264+
return http.ErrUseLastResponse
265+
},
266+
}
262267
proxyReq, err := http.NewRequest(gamezipRequest.Method, gamezipRequest.URL.String(), gamezipRequest.Body)
263268
if err != nil {
264269
fmt.Printf("UNHANDLED GAMEZIP ERROR: %s\n", err)

0 commit comments

Comments
 (0)