go-rod / rod

A Chrome DevTools Protocol driver for web automation and scraping.
https://go-rod.github.io
MIT License
5.42k stars 356 forks source link

add GetBody in hijack LoadResponse request for http2 retry #1128

Open pyneda opened 1 month ago

pyneda commented 1 month ago

Fix for the following error

(http2: Transport: cannot retry err [stream error: stream ID 1; PROTOCOL_ERROR; received from peer] after Request.Body was written; define Request.GetBody to avoid this error)
pyneda commented 1 month ago

Could you add at least a test for it?

Attempted to set up a test case using an HTTP/2 test server and a client that forces retries to reproduce the original issue. However, I wasn't able to replicate the same error within a test case.

As a fallback, added a simpler test that ensures the request body is correctly propagated through redirects and verifies that the GetBody function added in LoadResponse behaves as expected.

Some related issues: https://github.com/stripe/stripe-go/issues/710 https://github.com/connectrpc/connect-go/issues/541