@mentra/crust 3.4.0-dev.966 → 3.4.0-dev.971
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -100,22 +100,25 @@ public enum JSCPolyfillBridge {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
var urlRequest = URLRequest(url: url)
|
|
103
|
-
|
|
103
|
+
let method = (req["method"] as? String) ?? "GET"
|
|
104
|
+
urlRequest.httpMethod = method
|
|
104
105
|
if let headers = req["headers"] as? [String: Any] {
|
|
105
106
|
for (k, v) in headers {
|
|
106
107
|
urlRequest.setValue(String(describing: v), forHTTPHeaderField: k)
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
// ArrayBuffer and typed-array bodies arrive as base64 of their bytes.
|
|
111
|
+
// As on Android, an empty body is still sent, and POST, PUT and PATCH
|
|
112
|
+
// always carry one, so the server sees Content-Length: 0.
|
|
110
113
|
if let encoded = req["bodyBase64"] as? String {
|
|
111
114
|
guard let data = Data(base64Encoded: encoded) else {
|
|
112
115
|
return .error(code: "INVALID_ARGS", message: "fetch.request: bodyBase64 is not base64")
|
|
113
116
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
} else if
|
|
118
|
-
urlRequest.httpBody =
|
|
117
|
+
urlRequest.httpBody = data
|
|
118
|
+
} else if let body = req["body"] as? String {
|
|
119
|
+
urlRequest.httpBody = Data(body.utf8)
|
|
120
|
+
} else if ["POST", "PUT", "PATCH"].contains(method.uppercased()) {
|
|
121
|
+
urlRequest.httpBody = Data()
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
// Reasonable defaults — caller can override later by passing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mentra/crust",
|
|
3
|
-
"version": "3.4.0-dev.
|
|
3
|
+
"version": "3.4.0-dev.971",
|
|
4
4
|
"description": "Mentra Native Module",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"license": "Apache-2.0",
|
|
36
36
|
"homepage": "https://github.com/Mentra-Community/MentraOS/tree/dev/mobile/modules/crust#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@mentra/jspolyfill": "3.4.0-dev.
|
|
38
|
+
"@mentra/jspolyfill": "3.4.0-dev.971"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@expo/config-plugins": ">=8.0.0",
|