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

Android Custom Protocol always returns an empty body #1448

Open
jkelleyrtp opened this issue Jan 8, 2025 · 0 comments
Open

Android Custom Protocol always returns an empty body #1448

jkelleyrtp opened this issue Jan 8, 2025 · 0 comments

Comments

@jkelleyrtp
Copy link

jkelleyrtp commented Jan 8, 2025

The code for creating request bodies on android always sets the body to be an empty vec:

wry/src/android/binding.rs

Lines 160 to 167 in cbbcccc

let final_request = match request_builder.body(Vec::new()) {
Ok(req) => req,
Err(e) => {
#[cfg(feature = "tracing")]
tracing::warn!("Failed to build response: {}", e);
return Ok(*JObject::null());
}
};

No other platforms do this, breaking custom protocol support on android.

The core reason is because android's shouldInterceptRequest doesn't provide the body. I would imagine wry should paper over this issue rather than let it bubble up to user code.

You can work around this by exposing a JavaScriptInterface object to the webview as shown here

https://github.com/acsbendi/Android-Request-Inspector-WebView/blob/master/app/src/main/java/com/acsbendi/requestinspectorwebview/RequestInspectorJavaScriptInterface.kt

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

1 participant