summaryrefslogtreecommitdiff
path: root/opendc-common/src/main/kotlin/org/opendc/common/utils/HTTPClient.kt
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-common/src/main/kotlin/org/opendc/common/utils/HTTPClient.kt')
-rw-r--r--opendc-common/src/main/kotlin/org/opendc/common/utils/HTTPClient.kt17
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
+}