Skip to content

How to modify the headers of a response? #6187

Answered by FabianLars
FlysoftBeta asked this question in Q&A
Discussion options

You must be logged in to vote

The WebResourceResponseReceived event can not be used to modify the Responses, only to monitor them. If you want to modify a Response, you need to listen to the WebResourceResourceRequested event, cancel the request, do your own request stuff (via reqwest for example), modify that response and then send it back to the webview. Example from Microsoft docs: https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/webresourcerequested?tabs=dotnet#example-overriding-a-response-to-proactively-replace-it

And the upstream feature request: MicrosoftEdge/WebView2Feedback#2355 - Note that this does not exist on the linux and macos webviews either (but worse because you can't modify requests…

Replies: 4 comments 14 replies

Comment options

You must be logged in to vote
1 reply
@FlysoftBeta
Comment options

Answer selected by FlysoftBeta
Comment options

You must be logged in to vote
5 replies
@FabianLars
Comment options

@107295472
Comment options

@FabianLars
Comment options

@107295472
Comment options

Comment options

You must be logged in to vote
8 replies
@cck190891
Comment options

@107295472
Comment options

@cck190891
Comment options

@FabianLars
Comment options

@cck190891
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants