From 1189e2a2d5ee18ad83281eea92b05a93f9184ebf Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Wed, 16 Oct 2024 01:47:14 +0200 Subject: [PATCH] fix(macos): fix malformed headers in custom protocol response (#1392) --- .changes/fix-malformed-headers.md | 5 +++++ src/wkwebview/class/url_scheme_handler.rs | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changes/fix-malformed-headers.md diff --git a/.changes/fix-malformed-headers.md b/.changes/fix-malformed-headers.md new file mode 100644 index 000000000..91cfb1eb2 --- /dev/null +++ b/.changes/fix-malformed-headers.md @@ -0,0 +1,5 @@ +--- +"wry": "patch" +--- + +Fix malformed headers in custom protocol response on macOS. diff --git a/src/wkwebview/class/url_scheme_handler.rs b/src/wkwebview/class/url_scheme_handler.rs index b0aaf8937..07bb514af 100644 --- a/src/wkwebview/class/url_scheme_handler.rs +++ b/src/wkwebview/class/url_scheme_handler.rs @@ -203,13 +203,13 @@ extern "C" fn start_task( if let Some(mime) = wanted_mime { headers.insert_id( - NSString::from_str(mime.to_str().unwrap()).as_ref(), - NSString::from_str(CONTENT_TYPE.as_str()), + NSString::from_str(CONTENT_TYPE.as_str()).as_ref(), + NSString::from_str(mime.to_str().unwrap()), ); } headers.insert_id( - NSString::from_str(&content.len().to_string()).as_ref(), - NSString::from_str(CONTENT_LENGTH.as_str()), + NSString::from_str(CONTENT_LENGTH.as_str()).as_ref(), + NSString::from_str(&content.len().to_string()), ); // add headers