@cappitolian/http-local-server-swifter 0.0.4 → 0.0.6

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.
@@ -52,6 +52,7 @@ dependencies {
52
52
  implementation fileTree(dir: 'libs', include: ['*.jar'])
53
53
  implementation project(':capacitor-android')
54
54
  implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
+ implementation "org.nanohttpd:nanohttpd:2.3.1"
55
56
  testImplementation "junit:junit:$junitVersion"
56
57
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
58
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
@@ -168,21 +168,32 @@ public protocol HttpLocalServerSwifterDelegate: AnyObject {
168
168
  }
169
169
 
170
170
  private func extractBody(from request: HttpRequest) -> String? {
171
- guard let bodyBytes = request.body,
172
- !bodyBytes.isEmpty else {
171
+ // request.body ya es [UInt8], no es opcional
172
+ let bodyBytes = request.body
173
+
174
+ guard !bodyBytes.isEmpty else {
173
175
  return nil
174
176
  }
175
-
177
+
176
178
  return String(bytes: bodyBytes, encoding: .utf8)
177
179
  }
178
180
 
179
181
  private func extractHeaders(from request: HttpRequest) -> [String: String] {
180
- // Swifter's headers is [(String, String)]
181
- return Dictionary(uniqueKeysWithValues: request.headers)
182
+ // Swifter headers es [(String, String)], convertir a [String: String]
183
+ var headersDict: [String: String] = [:]
184
+ for (key, value) in request.headers {
185
+ headersDict[key] = value
186
+ }
187
+ return headersDict
182
188
  }
183
189
 
184
190
  private func extractQuery(from request: HttpRequest) -> [String: String] {
185
- return request.queryParams
191
+ // request.queryParams también es [(String, String)]
192
+ var queryDict: [String: String] = [:]
193
+ for (key, value) in request.queryParams {
194
+ queryDict[key] = value
195
+ }
196
+ return queryDict
186
197
  }
187
198
 
188
199
  private func createJsonResponse(_ body: String, statusCode: Int = 200) -> HttpResponse {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cappitolian/http-local-server-swifter",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Runs a local HTTP server on your device, accessible over LAN. Supports connect, disconnect, GET, and POST methods with IP and port discovery.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",