diff --git a/photon-server/src/main/java/org/photonvision/server/RequestHandler.java b/photon-server/src/main/java/org/photonvision/server/RequestHandler.java index 0ea9f05d79..1e8cf51fb3 100644 --- a/photon-server/src/main/java/org/photonvision/server/RequestHandler.java +++ b/photon-server/src/main/java/org/photonvision/server/RequestHandler.java @@ -349,12 +349,12 @@ public static void onOfflineUpdateRequest(Context ctx) { public static void onGeneralSettingsRequest(Context ctx) { NetworkConfig config; try { - config = kObjectMapper.readValue(ctx.body(), NetworkConfig.class); + config = kObjectMapper.readValue(ctx.bodyInputStream(), NetworkConfig.class); ctx.status(200); ctx.result("Successfully saved general settings"); logger.info("Successfully saved general settings"); - } catch (JsonProcessingException e) { + } catch (IOException e) { // If the settings can't be parsed, use the default network settings config = new NetworkConfig(); @@ -381,7 +381,7 @@ public static class UICameraSettingsRequest { public static void onCameraSettingsRequest(Context ctx) { try { - var data = kObjectMapper.readTree(ctx.body()); + var data = kObjectMapper.readTree(ctx.bodyInputStream()); int index = data.get("index").asInt(); var settings = @@ -451,7 +451,7 @@ public static void onCalibrationEndRequest(Context ctx) { int index; try { - index = kObjectMapper.readTree(ctx.body()).get("index").asInt(); + index = kObjectMapper.readTree(ctx.bodyInputStream()).get("index").asInt(); var calData = VisionModuleManager.getInstance().getModule(index).endCalibration(); if (calData == null) { @@ -482,7 +482,7 @@ public static void onCalibrationEndRequest(Context ctx) { } public static void onCalibDBCalibrationImportRequest(Context ctx) { - var data = ctx.body(); + var data = ctx.bodyInputStream(); try { var actualObj = kObjectMapper.readTree(data); @@ -503,7 +503,7 @@ public static void onCalibDBCalibrationImportRequest(Context ctx) { ctx.status(200); ctx.result("Calibration imported successfully from CalibDB data!"); logger.info("Calibration imported successfully from CalibDB data!"); - } catch (JsonProcessingException e) { + } catch (IOException e) { ctx.status(400); ctx.result( "The Provided CalibDB data is malformed and cannot be parsed for the required fields."); @@ -515,7 +515,7 @@ public static void onCalibDBCalibrationImportRequest(Context ctx) { public static void onDataCalibrationImportRequest(Context ctx) { try { - var data = kObjectMapper.readTree(ctx.body()); + var data = kObjectMapper.readTree(ctx.bodyInputStream()); int cameraIndex = data.get("cameraIndex").asInt(); var coeffs = @@ -557,7 +557,7 @@ public static void onDeviceRestartRequest(Context ctx) { public static void onCameraNicknameChangeRequest(Context ctx) { try { - var data = kObjectMapper.readTree(ctx.body()); + var data = kObjectMapper.readTree(ctx.bodyInputStream()); String name = data.get("name").asText(); int idx = data.get("cameraIndex").asInt(); diff --git a/photon-server/src/main/java/org/photonvision/server/Server.java b/photon-server/src/main/java/org/photonvision/server/Server.java index 0fc0d97f01..143e099c98 100644 --- a/photon-server/src/main/java/org/photonvision/server/Server.java +++ b/photon-server/src/main/java/org/photonvision/server/Server.java @@ -65,10 +65,6 @@ private static void start(int port) { corsContainer.add(CorsPluginConfig::anyHost); }); - // Increase the upload size limit (arbitrary, but need to be able to deal with large - // calibration JSONs) - javalinConfig.http.maxRequestSize = (long) (50 * 1e6); - javalinConfig.requestLogger.http( (ctx, ms) -> { StringJoiner joiner = @@ -77,6 +73,12 @@ private static void start(int port) { .add(ctx.req().getMethod()) .add("from endpoint") .add(ctx.path()) + .add("of req size") + .add(Integer.toString(ctx.contentLength())) + .add("bytes & type") + .add(ctx.contentType()) + .add("with return code") + .add(Integer.toString(ctx.res().getStatus())) .add("for host") .add(ctx.req().getRemoteHost()) .add("in")