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

Add shouldInterceptRequest method #180

Open
TelephoneTan opened this issue Jun 18, 2024 · 5 comments
Open

Add shouldInterceptRequest method #180

TelephoneTan opened this issue Jun 18, 2024 · 5 comments
Assignees

Comments

@TelephoneTan
Copy link

Android WebView has a method called shouldInterceptRequest, it is used to support fully control over every request. We can use whatever we want as the response of the request by using this method.

It's good to have such method or any similar feature.

Here is my use case with Android WebView's shouldInterceptRequest:

I need to send some large messages(big image in base64 encoding, eg.) to js code, but the Android WebView has a maximum limit on the size of the data exchanged between js code and java code through the @JavascriptInterface(aka the js-bridge), so the ONLY way to achieve this is to make a "fake" HTTP request with a special url from js side, and "catch" this request in java side using shouldInterceptRequest, construct a HTTP response using the large message as the response body, and extract the large message from the HTTP response in js side later.

By the way, according to SO, it seems that we can use WKURLSchemeHandler to implement an iOS version of shouldInterceptRequest method.

@KevinnZou
Copy link
Owner

@TelephoneTan Thanks for your suggestion! I will add it to our feature plan. Feel free to submit a PR for it as well!

@KevinnZou KevinnZou self-assigned this Jun 20, 2024
@TelephoneTan
Copy link
Author

Is there any progress on this feature?

@jccr
Copy link

jccr commented Aug 29, 2024

I am looking for this as well. Maybe I could help contribute this in?

@KevinnZou
Copy link
Owner

I am looking for this as well. Maybe I could help contribute this in?

@jccr Sure, feel free to do it!

@AbrahamOEd
Copy link

Do you accept changes for Android only, or would every change need to support both ios and android? I have worked with implementing shouldInterceptRequest in react native

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

4 participants