Response header bug fixed for Chrome

This commit is contained in:
Musab Gültekin 2019-06-18 16:37:06 +03:00
parent ec83a92eb3
commit c28b228a12

View File

@ -265,6 +265,7 @@ func (g *Geziyor) doRequestChrome(req *Request) (*Response, error) {
defer cancel() defer cancel()
var body string var body string
var reqID network.RequestID
var res *network.Response var res *network.Response
if err := chromedp.Run(ctx, if err := chromedp.Run(ctx,
@ -273,8 +274,14 @@ func (g *Geziyor) doRequestChrome(req *Request) (*Response, error) {
chromedp.ActionFunc(func(ctx context.Context) error { chromedp.ActionFunc(func(ctx context.Context) error {
chromedp.ListenTarget(ctx, func(ev interface{}) { chromedp.ListenTarget(ctx, func(ev interface{}) {
switch ev.(type) { switch ev.(type) {
case *network.EventRequestWillBeSent:
if reqEvent := ev.(*network.EventRequestWillBeSent); reqEvent.Request.URL == req.URL.String() {
reqID = reqEvent.RequestID
}
case *network.EventResponseReceived: case *network.EventResponseReceived:
res = ev.(*network.EventResponseReceived).Response if resEvent := ev.(*network.EventResponseReceived); resEvent.RequestID == reqID {
res = resEvent.Response
}
} }
}) })
return nil return nil