瀏覽代碼

fix phaser sprite loading bug (#1717)

* fix phaser sprite loading bug
the reason was the missing http status code

* avoid using forced unwrapping and duplicated code

Co-authored-by: cyberta <cyberta@riseup.net>
Simon Laux 2 年之前
父節點
當前提交
5a43b5a118
共有 1 個文件被更改,包括 12 次插入2 次删除
  1. 12 2
      deltachat-ios/Controller/WebxdcViewController.swift

+ 12 - 2
deltachat-ios/Controller/WebxdcViewController.swift

@@ -381,8 +381,18 @@ extension WebxdcViewController: WKURLSchemeHandler {
                 data = dcMsg.getWebxdcBlob(filename: file)
             }
             let mimeType = DcUtils.getMimeTypeForPath(path: file)
-            let response = URLResponse(url: url, mimeType: mimeType, expectedContentLength: data.count, textEncodingName: nil)
-            
+            let statusCode = (data.isEmpty ? 404 : 200)
+            guard let response = HTTPURLResponse(
+                url: url,
+                statusCode: statusCode,
+                httpVersion: "HTTP/1.1",
+                headerFields: [
+                    "Content-Type": mimeType,
+                    "Content-Length": "\(data.count)"
+                ]
+            ) else {
+                return
+            }
             urlSchemeTask.didReceive(response)
             urlSchemeTask.didReceive(data)
             urlSchemeTask.didFinish()