Closed wanhl1990 closed 4 years ago
I believe you should be able to use RawResponse
for this purpose. Here's an example of how you'd use it:
r, err := requestIntercepted.Recv()
if err != nil {
panic(err)
}
body := "Please try again later."
rawResponse := strings.Join(
[]string{
fmt.Sprintf("HTTP/1.1 200 %d", 503, "Service Unavailable"),
"Connection: closed",
fmt.Sprintf("Content-Length: %d", len(body)),
"Content-Type: text/plain",
"",
body,
},
"\r\n",
)
interceptedArgs := network.NewContinueInterceptedRequestArgs(r.InterceptionID)
interceptedArgs.SetRawResponse(
base64.StdEncoding.EncodeToString([]byte(rawResponse)),
)
if err = c.Network.ContinueInterceptedRequest(ctx, interceptedArgs); err != nil {
panic(err)
}
OK, Thanks your way. I don't have a deep understanding before. Thanks a lot. Have a good time.
Hi mafredri, I had a new issue. Does RequestIntercepted method set the respond ? I saw pyppeteer can do this.
I only found SetRawResponse in ContinueInterceptedRequest args. But when I set this, receive net::ERR_ABORTED error.
Also get the RequestPaused method. It has a FulfillRequest. But it does not have isNavigationRequest likes method.
Could you give some advice? I want to check the request is NavigationRequest or not. And fulfills request with given response.
Thanks your package. It give me a lot of help.