Skip to content

Commit

Permalink
Remove id parameter for GET requests (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjaros committed Mar 2, 2024
1 parent 2f94dc6 commit 6b05c75
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ open class CallAgent {
val jsonRpcRequest = JsonRpcRequest(counter++, url, data)
val urlAddr = urlPrefix + url.drop(1)
val fetchUrl = if (method == HttpMethod.GET) {
val paramsObject = obj { id = jsonRpcRequest.id }
val paramsObject = obj {}
data.forEachIndexed { index, s ->
if (s != null) paramsObject["p$index"] = encodeURIComponent(s)
}
Expand All @@ -106,7 +106,7 @@ open class CallAgent {
if (response.ok && response.headers.get("Content-Type") == "application/json") {
response.json().then { data: dynamic ->
when {
data.id != jsonRpcRequest.id -> cont.cancel(Exception("Invalid response ID"))
method != HttpMethod.GET && data.id != jsonRpcRequest.id -> cont.cancel(Exception("Invalid response ID"))
data.error != null -> {
if (data.exceptionType == "io.kvision.remote.ServiceException") {
cont.cancel(ServiceException(data.error.toString()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import com.google.inject.Injector
import io.javalin.Javalin
import io.javalin.http.Context
import io.javalin.http.bodyAsClass
import io.javalin.http.queryParamAsClass
import io.javalin.http.sse.SseClient
import io.javalin.security.RouteRole
import io.javalin.websocket.WsConfig
Expand Down Expand Up @@ -82,7 +81,7 @@ actual open class KVServiceManager<out T : Any> actual constructor(private val s
URLDecoder.decode(it, StandardCharsets.UTF_8)
}
}
JsonRpcRequest(ctx.queryParamAsClass<Int>("id").get(), "", parameters)
JsonRpcRequest(0, "", parameters)
} else {
ctx.bodyAsClass()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ actual open class KVServiceManager<out T : Any> actual constructor(private val s
URLDecoder.decode(it, StandardCharsets.UTF_8)
}
}
JsonRpcRequest(ctx.query("id").intValue(), "", parameters)
JsonRpcRequest(0, "", parameters)
} else {
ctx.body(JsonRpcRequest::class.java)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ actual open class KVServiceManager<out T : Any> actual constructor(private val s
URLDecoder.decode(it, StandardCharsets.UTF_8)
}
}
JsonRpcRequest(call.request.queryParameters["id"]?.toInt() ?: 0, "", parameters)
JsonRpcRequest(0, "", parameters)
} else {
call.receive()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ actual open class KVServiceManager<out T : Any> actual constructor(private val s
URLDecoder.decode(it, StandardCharsets.UTF_8)
}
}
JsonRpcRequest(call.request.queryParameters["id"]?.toInt() ?: 0, "", parameters)
JsonRpcRequest(0, "", parameters)
} else {
call.receive()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ actual open class KVServiceManager<out T : Any> actual constructor(private val s
URLDecoder.decode(it, StandardCharsets.UTF_8)
}
}
JsonRpcRequest(req.parameters["id"]?.toInt() ?: 0, "", parameters)
JsonRpcRequest(0, "", parameters)
} else {
req.getBody(JsonRpcRequest::class.java).get()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ actual open class KVServiceManager<out T : Any> actual constructor(private val s
URLDecoder.decode(it, StandardCharsets.UTF_8)
}
}
JsonRpcRequest(req.queryParam("id").map { it.toInt() }.orElse(0), "", parameters)
JsonRpcRequest(0, "", parameters)
} else {
req.awaitBody()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ actual open class KVServiceManager<out T : Any> actual constructor(private val s
URLDecoder.decode(it, StandardCharsets.UTF_8)
}
}
JsonRpcRequest(ctx.request().getParam("id")?.toInt() ?: 0, "", parameters)
JsonRpcRequest(0, "", parameters)
} else {
ctx.body().asJsonObject().mapTo(JsonRpcRequest::class.java)
}
Expand Down

0 comments on commit 6b05c75

Please sign in to comment.