Skip to content
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

How to modify the postData in a Request #20

Open
spikeruk opened this issue Jan 18, 2025 · 2 comments
Open

How to modify the postData in a Request #20

spikeruk opened this issue Jan 18, 2025 · 2 comments

Comments

@spikeruk
Copy link

spikeruk commented Jan 18, 2025

Hi,
I am try to change the text in the request body

 pageClient.SubscribeAsync<Fetch.RequestPaused>(async req =>
 {
         if (req.Request.HasPostData == true)
         {
             String postData = req.Request.PostData;
             String modifiedPostData = postData.Replace("ping", "pong");
             byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes(modifiedPostData);
             string base64EncodedText = System.Convert.ToBase64String(plainTextBytes);

             await pageClient.SendCommandAsync(Fetch.ContinueRequest(req.RequestId, req.Request.Url, req.Request.Method, base64EncodedText, req.ResponseHeaders));
         }
     }
     await pageClient.SendCommandAsync(Fetch.ContinueRequest(req.RequestId));
 });

Why would this not work?

@spikeruk
Copy link
Author

spikeruk commented Jan 18, 2025

Seems to work if I use:

 await pageClient.SendCommandAsync(Fetch.ContinueRequest(req.RequestId, null, null, base64EncodedText));

rather than

await pageClient.SendCommandAsync(Fetch.ContinueRequest(req.RequestId, req.Request.Url, req.Request.Method, base64EncodedText, req.ResponseHeaders));

@seclerp
Copy link
Owner

seclerp commented Jan 20, 2025

What do you mean by "not work"?

I can only assume the problem might be in the versions incompatibility. The latest ChromeProtocol.Domains package supports Chrome revision that equals or greater than 1367902, with the nearest stable release resolves to 131.0.6778.33 Chrome version.

Older versions of Chrome might have protocol differences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants