Skip to content

Commit

Permalink
fix(android): skip duplicated Content-Type/Content-Length header to fix
Browse files Browse the repository at this point in the history
tauri-apps/tauri#8857 (#1360)

* fix(android): skip duplicated Content-Type/Content-Length header to fix tauri-apps/tauri#8857

* fix(android): added comment and change log
  • Loading branch information
Steve-xmh authored Sep 10, 2024
1 parent b863d38 commit 170095b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wry": patch
---

Fix web resource loading in android binding by skip duplicate Content-Type/Content-Length headers.
7 changes: 6 additions & 1 deletion src/android/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: MIT

use http::{
header::{HeaderName, HeaderValue, CONTENT_TYPE},
header::{HeaderName, HeaderValue, CONTENT_LENGTH, CONTENT_TYPE},
Request,
};
use jni::errors::Result as JniResult;
Expand Down Expand Up @@ -216,6 +216,11 @@ fn handle_request(
let response_headers = {
let headers_map = JMap::from_env(env, &obj)?;
for (name, value) in headers.iter() {
// WebResourceResponse will automatically generate Content-Type and
// Content-Length headers so we should skip them to avoid duplication.
if name == CONTENT_TYPE || name == CONTENT_LENGTH {
continue;
}
let key = env.new_string(name)?;
let value = env.new_string(value.to_str().unwrap_or_default())?;
headers_map.put(env, &key, &value)?;
Expand Down

0 comments on commit 170095b

Please sign in to comment.