Skip to content

Commit 86243bc

Browse files
committed
Refine WKURLSchemeTask body handling
1 parent 3042ef1 commit 86243bc

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/wkwebview/class/url_scheme_handler.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ extern "C" fn start_task(
216216
check_webview_id_valid(webview_id)?;
217217
check_task_is_valid(&webview, task_key, task_uuid.clone())?;
218218

219-
let content = sent_response.body();
220-
let content_len = content.len();
219+
let content_len = sent_response.body().len();
221220
// default: application/octet-stream, but should be provided by the client
222221
let wanted_mime = sent_response.headers().get(CONTENT_TYPE);
223222
// default to 200
@@ -267,11 +266,12 @@ extern "C" fn start_task(
267266
}))
268267
.map_err(|_e| crate::Error::CustomProtocolTaskInvalid)?;
269268

269+
let content = sent_response.into_body();
270270
let data = if content_len < NO_COPY_DATA_THRESHOLD {
271271
// Keep small responses on the original copy path; no-copy deallocation costs more.
272-
NSData::with_bytes(content)
272+
NSData::with_bytes(content.as_ref())
273273
} else {
274-
match sent_response.into_body() {
274+
match content {
275275
Cow::Owned(content) => NSData::from_vec(content),
276276
Cow::Borrowed(content) => {
277277
// Copy borrowed responses because NSData cannot take ownership.

0 commit comments

Comments
 (0)