diff options
| author | mjkwiatkowski <mati.rewa@gmail.com> | 2026-06-19 10:57:10 +0200 |
|---|---|---|
| committer | mjkwiatkowski <mati.rewa@gmail.com> | 2026-06-19 10:57:10 +0200 |
| commit | ca0c72789ba87791829001d259000b2966d9d6e4 (patch) | |
| tree | 8e488741389a24acc30d02b742398935586c54c9 /opendc-common/src | |
| parent | 54f94861da743cbd72d9755c2fbe4223176d90f4 (diff) | |
feat: added additional capability to HTTPClient
Diffstat (limited to 'opendc-common/src')
| -rw-r--r-- | opendc-common/src/main/kotlin/org/opendc/common/utils/HTTPClient.kt | 17 |
1 files changed, 13 insertions, 4 deletions
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 +} |
