@cantoo/capacitor-http-server
Advanced tools
@@ -137,3 +137,8 @@ package com.cantooscribe.httpserver | ||
| } catch (e: Throwable) { | ||
| call.reject("Failed to start server: ${e.message}", e) | ||
| // PluginCall.reject(String, Exception) cannot accept a raw | ||
| // Throwable, so wrap errors (OOM, etc.) in an Exception. | ||
| call.reject( | ||
| "Failed to start server: ${e.message}", | ||
| e as? Exception ?: RuntimeException(e) | ||
| ) | ||
| return | ||
@@ -179,3 +184,6 @@ } | ||
| try { srv?.stop() } catch (_: Throwable) {} | ||
| call.reject("Failed to start foreground service: ${e.message}", e) | ||
| call.reject( | ||
| "Failed to start foreground service: ${e.message}", | ||
| e as? Exception ?: RuntimeException(e) | ||
| ) | ||
| return | ||
@@ -471,4 +479,6 @@ } | ||
| entry?.tempFile?.let { runCatching { it.delete() } } | ||
| // NanoHTTPD 2.3.1 does not expose 504 in Response.Status, | ||
| // so build a custom IStatus via HttpRequestBridge.statusOf. | ||
| return newFixedLengthResponse( | ||
| Response.Status.GATEWAY_TIMEOUT, | ||
| HttpRequestBridge.statusOf(504), | ||
| "text/plain", | ||
@@ -475,0 +485,0 @@ "JS handler did not respond in time" |
+1
-1
| { | ||
| "name": "@cantoo/capacitor-http-server", | ||
| "version": "1.0.2", | ||
| "version": "1.0.3", | ||
| "description": "Capacitor plugin exposing a local HTTP server on iOS and Android with routing delegated to JavaScript.", | ||
@@ -5,0 +5,0 @@ "main": "dist/plugin.cjs.js", |
110099
0.47%