Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 170095b

Browse files
authored
fix(android): skip duplicated Content-Type/Content-Length header to fix 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
1 parent b863d38 commit 170095b

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wry": patch
3+
---
4+
5+
Fix web resource loading in android binding by skip duplicate Content-Type/Content-Length headers.

src/android/binding.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// SPDX-License-Identifier: MIT
44

55
use http::{
6-
header::{HeaderName, HeaderValue, CONTENT_TYPE},
6+
header::{HeaderName, HeaderValue, CONTENT_LENGTH, CONTENT_TYPE},
77
Request,
88
};
99
use jni::errors::Result as JniResult;
@@ -216,6 +216,11 @@ fn handle_request(
216216
let response_headers = {
217217
let headers_map = JMap::from_env(env, &obj)?;
218218
for (name, value) in headers.iter() {
219+
// WebResourceResponse will automatically generate Content-Type and
220+
// Content-Length headers so we should skip them to avoid duplication.
221+
if name == CONTENT_TYPE || name == CONTENT_LENGTH {
222+
continue;
223+
}
219224
let key = env.new_string(name)?;
220225
let value = env.new_string(value.to_str().unwrap_or_default())?;
221226
headers_map.put(env, &key, &value)?;

0 commit comments

Comments
 (0)