From ca0c72789ba87791829001d259000b2966d9d6e4 Mon Sep 17 00:00:00 2001 From: mjkwiatkowski Date: Fri, 19 Jun 2026 10:57:10 +0200 Subject: feat: added additional capability to HTTPClient --- .../main/kotlin/org/opendc/common/utils/HTTPClient.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'opendc-common/src/main') diff --git a/opendc-common/src/main/kotlin/org/opendc/common/utils/HTTPClient.kt b/opendc-common/src/main/kotlin/org/opendc/common/utils/HTTPClient.kt index fc5bc57b..f8e5e120 100644 --- a/opendc-common/src/main/kotlin/org/opendc/common/utils/HTTPClient.kt +++ b/opendc-common/src/main/kotlin/org/opendc/common/utils/HTTPClient.kt @@ -26,7 +26,16 @@ public class HTTPClient private constructor() { } } - // TODO: this class must send the experiment JSON file to the digital twin + public fun checkForInsights(){ + val request = HttpRequest.newBuilder() + .uri(URI.create("http://localhost:1234/check")) + .header("Content-type", "text/plain") + .GET() + .build() + val response = client?.send(request, ofString()) + check(response?.statusCode() == 200) + } + public fun sendExperiment(experiment: File) { val input = experiment.inputStream() val charArray = CharArray(experiment.length().toInt()) @@ -35,12 +44,12 @@ public class HTTPClient private constructor() { isr.read(charArray) val request = HttpRequest.newBuilder() - .uri(URI.create("http://localhost:8080/assets")) + .uri(URI.create("http://localhost:1234/assets")) .header("Content-type", "application/json") - // TODO: this is obviously wrong, find an efficient way to send JSON over network + // TODO(this is obviously wrong, find an efficient way to send JSON over network) .POST(HttpRequest.BodyPublishers.ofString(String(charArray))) .build() val response = client?.send(request, ofString()) check(response?.statusCode() == 200) } -} \ No newline at end of file +} -- cgit v1.2.3