Skip to content

Android Custom Protocol always returns an empty body #1448

@jkelleyrtp

Description

@jkelleyrtp

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions