-
-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read body from NetworkResponseReceived event #864
Comments
Please fix the format of your markdown: 5 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"] generated by check-issue |
Line 87 in 49cd11c
|
Thanks for your answer ! However, I felt like it would make sense to have access to the response body from the |
Then I think it's not related to Rod, you can ask the chromium team to support it: https://developer.chrome.com/docs/devtools/ |
right, thanks for the details ! |
maybe you need this |
Sorry to resurrect, but I'm trying to get the response body from a Service Worker that intercepted the request. I'm using I had to use @ischeck's approach, which results in this error:
Any ideas? |
@lukeed You can use go run main.go -rod=cdp |
@ysmood Thanks for the info. The RequestID does, in fact, exist: fetch := fmt.Sprintf(`function() { return fetch(%q, %s) }`, r.URL, string(bytes))
fmt.Printf("\nFETCH:\n%s\n\n", fetch)
e := proto.NetworkResponseReceived{}
wait := page.WaitEvent(&e)
if _, err := page.Eval(fetch); err != nil {
fmt.Printf("\nEVAL ERROR:\n%v\n\n", err)
}
fmt.Println("\nWAITING...")
wait()
fmt.Println("\nWAITED!")
fmt.Println("e.res.url", e.Response.URL)
fmt.Println("e.requestID", e.RequestID)
reply, err := (proto.NetworkGetResponseBody{RequestID: e.RequestID}).Call(page)
if err != nil {
fmt.Println("ERROR: ", err)
return
}
|
@lukeed I think you need to find out the correct |
I was on the correct page. What I needed was to wait for the NetworkLoadingFinished event & then ask for the Similarly I only randomly see |
We'd better raise another issue for service worker, I confirmed that it's not easy to get the request events from it. |
How to get the body |
Your code will not run in the latest version without Body |
I hope it helps others
|
@duolabmeng6 i still face the issue by using your sample code any idea? |
Googling how ppl to solve the issue Refactor to use the event
|
Rod Version: v0.112.8
The code to demonstrate your question
What you got
The NetworkResponseReceived object, but I'm looking for the body of the response (which in this case is some json)
What have you tried to solve the question
Searching in the doc, the internet, ask chatGPT
The text was updated successfully, but these errors were encountered: