This avoids the corner case where `via` is not nil, but has a length of 0,
so the updated code does not panic in that situation.
Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
| ... | ... |
@@ -145,7 +145,7 @@ func trustedLocation(req *http.Request) bool {
|
| 145 | 145 |
// addRequiredHeadersToRedirectedRequests adds the necessary redirection headers |
| 146 | 146 |
// for redirected requests |
| 147 | 147 |
func addRequiredHeadersToRedirectedRequests(req *http.Request, via []*http.Request) error {
|
| 148 |
- if via != nil && via[0] != nil {
|
|
| 148 |
+ if len(via) != 0 && via[0] != nil {
|
|
| 149 | 149 |
if trustedLocation(req) && trustedLocation(via[0]) {
|
| 150 | 150 |
req.Header = via[0].Header |
| 151 | 151 |
return nil |