@capgo/capacitor-fast-sql 8.0.30 → 8.0.31

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.
@@ -19,7 +19,7 @@ import java.util.Map;
19
19
  @CapacitorPlugin(name = "CapgoCapacitorFastSql")
20
20
  public class CapgoCapacitorFastSqlPlugin extends Plugin {
21
21
 
22
- private final String pluginVersion = "8.0.30";
22
+ private final String pluginVersion = "8.0.31";
23
23
 
24
24
  private Map<String, DatabaseConnection> databases = new HashMap<>();
25
25
  private SQLHTTPServer server;
@@ -8,7 +8,9 @@ import com.google.gson.JsonElement;
8
8
  import com.google.gson.JsonObject;
9
9
  import com.google.gson.JsonParser;
10
10
  import fi.iki.elonen.NanoHTTPD; // Note: org.nanohttpd:nanohttpd:2.3.1 still uses fi.iki.elonen package
11
+ import java.io.DataInputStream;
11
12
  import java.io.IOException;
13
+ import java.nio.charset.StandardCharsets;
12
14
  import java.security.SecureRandom;
13
15
  import java.util.Map;
14
16
  import java.util.concurrent.ExecutionException;
@@ -105,11 +107,11 @@ public class SQLHTTPServer extends NanoHTTPD {
105
107
  } else if (method == Method.POST && uri.equals("/batch")) {
106
108
  return addCorsHeaders(handleBatch(session, db));
107
109
  } else if (method == Method.POST && uri.equals("/transaction/begin")) {
108
- return addCorsHeaders(handleBeginTransaction(db));
110
+ return addCorsHeaders(handleBeginTransaction(session, db));
109
111
  } else if (method == Method.POST && uri.equals("/transaction/commit")) {
110
- return addCorsHeaders(handleCommitTransaction(db));
112
+ return addCorsHeaders(handleCommitTransaction(session, db));
111
113
  } else if (method == Method.POST && uri.equals("/transaction/rollback")) {
112
- return addCorsHeaders(handleRollbackTransaction(db));
114
+ return addCorsHeaders(handleRollbackTransaction(session, db));
113
115
  } else {
114
116
  return addCorsHeaders(newFixedLengthResponse(Response.Status.NOT_FOUND, "text/plain", "Endpoint not found"));
115
117
  }
@@ -204,17 +206,20 @@ public class SQLHTTPServer extends NanoHTTPD {
204
206
  return newFixedLengthResponse(Response.Status.OK, "application/json", results.toString());
205
207
  }
206
208
 
207
- private Response handleBeginTransaction(DatabaseConnection db) throws Exception {
209
+ private Response handleBeginTransaction(IHTTPSession session, DatabaseConnection db) throws Exception {
210
+ readRequestBody(session); // drain any body to keep the connection clean for keep-alive
208
211
  db.beginTransaction();
209
212
  return newFixedLengthResponse(Response.Status.OK, "application/json", "{}");
210
213
  }
211
214
 
212
- private Response handleCommitTransaction(DatabaseConnection db) throws Exception {
215
+ private Response handleCommitTransaction(IHTTPSession session, DatabaseConnection db) throws Exception {
216
+ readRequestBody(session); // drain any body to keep the connection clean for keep-alive
213
217
  db.commitTransaction();
214
218
  return newFixedLengthResponse(Response.Status.OK, "application/json", "{}");
215
219
  }
216
220
 
217
- private Response handleRollbackTransaction(DatabaseConnection db) throws Exception {
221
+ private Response handleRollbackTransaction(IHTTPSession session, DatabaseConnection db) throws Exception {
222
+ readRequestBody(session); // drain any body to keep the connection clean for keep-alive
218
223
  db.rollbackTransaction();
219
224
  return newFixedLengthResponse(Response.Status.OK, "application/json", "{}");
220
225
  }
@@ -222,8 +227,8 @@ public class SQLHTTPServer extends NanoHTTPD {
222
227
  private String readRequestBody(IHTTPSession session) throws IOException {
223
228
  int contentLength = Integer.parseInt(session.getHeaders().get("content-length"));
224
229
  byte[] buffer = new byte[contentLength];
225
- session.getInputStream().read(buffer, 0, contentLength);
226
- return new String(buffer);
230
+ new DataInputStream(session.getInputStream()).readFully(buffer);
231
+ return new String(buffer, StandardCharsets.UTF_8);
227
232
  }
228
233
 
229
234
  private static String generateToken() {
@@ -10,7 +10,7 @@ import SQLite3
10
10
  */
11
11
  @objc(CapgoCapacitorFastSqlPlugin)
12
12
  public class CapgoCapacitorFastSqlPlugin: CAPPlugin, CAPBridgedPlugin {
13
- private let pluginVersion: String = "8.0.30"
13
+ private let pluginVersion: String = "8.0.31"
14
14
  public let identifier = "CapgoCapacitorFastSqlPlugin"
15
15
  public let jsName = "CapgoCapacitorFastSql"
16
16
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-fast-sql",
3
- "version": "8.0.30",
3
+ "version": "8.0.31",
4
4
  "description": "High-performance native SQLite plugin with custom protocol for efficient sync operations and IndexedDB replacement",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",