Skip to content

Commit 4d550d8

Browse files
committed
Fix panic when assign to nil header and cookie when host is not found
Closes #5213
1 parent a9f9e3b commit 4d550d8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/netext/httpext/request.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,12 @@ func MakeRequest(ctx context.Context, state *lib.State, preq *ParsedHTTPRequest)
229229
transport = ntlmssp.Negotiator{RoundTripper: transport}
230230
}
231231

232-
resp := &Response{URL: preq.URL.URL, Request: respReq}
232+
resp := &Response{
233+
URL: preq.URL.URL,
234+
Request: respReq,
235+
Headers: make(map[string]string),
236+
Cookies: make(map[string][]*HTTPCookie),
237+
}
233238
client := http.Client{
234239
Transport: transport,
235240
CheckRedirect: func(req *http.Request, via []*http.Request) error {

lib/netext/httpext/response.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ type Response struct {
7474
// NewResponse returns an empty Response instance.
7575
func NewResponse() *Response {
7676
return &Response{
77-
Body: []byte{},
77+
Headers: make(map[string]string),
78+
Cookies: make(map[string][]*HTTPCookie),
79+
Body: []byte{},
7880
}
7981
}
8082

0 commit comments

Comments
 (0)