1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-28 20:37:38 +00:00

Add support for HTTP timeouts (#1453)

- Add a `timeout` parameter to http request and websocket methods.
    - For requests, this sets the connection and read timeout.
    - For websockets, this sets the connection and handshake timeout.
 - Remove the timeout config option, as this is now specified by user
   code.
 - Use netty for handling websocket handshakes, meaning we no longer
   need to deal with pongs.
This commit is contained in:
Jonathan Coates
2023-05-23 23:32:16 +01:00
committed by GitHub
parent 55ed0dc3ef
commit 2ae14b4c08
13 changed files with 203 additions and 96 deletions

View File

@@ -4,6 +4,7 @@
package http
import dan200.computercraft.api.lua.ObjectArguments
import dan200.computercraft.core.CoreConfig
import dan200.computercraft.core.apis.HTTPAPI
import dan200.computercraft.core.apis.http.options.Action
@@ -45,7 +46,7 @@ class TestHttpApi {
LuaTaskRunner.runTest {
val httpApi = addApi(HTTPAPI(environment))
val result = httpApi.websocket(WS_ADDRESS, Optional.empty())
val result = httpApi.websocket(ObjectArguments(WS_ADDRESS))
assertArrayEquals(arrayOf(true), result, "Should have created websocket")
val event = pullEvent()