0

I am trying to find response size for every request from chromedp I tried following code

chromedp.ListenTarget(
    ctx,
    func(ev interface{}){
        if ev, ok := ev.(*network.EventResponseReceived); ok {
            fmt.Println("event received:")
            fmt.Println(ev.Type)
            var len = ev.Response.EncodedDataLength;
            fmt.Println(ev.Response.URL + ":" + fmt.Sprintf("%f", len))
            return

        }
    },
)

But EncodedDataLength is Total number of bytes received for this request so far (As per documentation). Is there any way to get full response size.

Thanks

JimB
  • 104,193
  • 13
  • 262
  • 255
Vishnu V
  • 382
  • 5
  • 16

1 Answers1

0

You can use EventLoadingFinished.

Network.loadingFinished #.
Fired when HTTP request has finished loading. as here

EventLoadingFinished.EncodedDataLength will give you the full size as this event will be triggered only once the entire response is loaded. You can use both the events and use the RequestID field to map them to a particular resource url.

poWar
  • 745
  • 6
  • 15