Julius
05/27/2022, 2:53 PMclient.webSocket(
method = HttpMethod.Get,
host = "localhost",
port = 8080,
path = "/ws",
request = {
header(
"My-Test-Header",
"My-Test-Header-Value"
)
}
) {
send(Frame.Text("Hello from client"))
while (true) {
val othersMessage = incoming.receive() as? Frame.Text
println(othersMessage?.readText())
val othersMessageText = othersMessage?.readText()
if (othersMessageText == "close") {
break
}
val myMessage = "Answer"
send(Frame.Text(myMessage))
}
}
It should at least allow the Sec-WebSocket-Protocol
header since that's part of the spec it seems.Aleksei Tirman [JB]
05/30/2022, 9:15 AMMy-Test-Header
header is actually sent while using the code from your example. I observe the same behavior with the Sec-WebSocket-Protocol
header.Julius
05/30/2022, 12:53 PMAleksei Tirman [JB]
05/30/2022, 12:55 PMclient.webSocket(
method = HttpMethod.Get,
host = "localhost",
port = 8080,
path = "/ws",
request = {
header(
"My-Test-Header",
"My-Test-Header-Value"
)
}
)
Julius
05/30/2022, 12:59 PM./gradlew browserDevelopmentRun
and automatically creates the websocket connection on browser loadAleksei Tirman [JB]
05/30/2022, 5:19 PMSec-WebSocket-Protocol
header.Julius
05/30/2022, 6:35 PMAleksei Tirman [JB]
05/30/2022, 6:46 PMJulius
05/30/2022, 6:52 PMfun createWebsocket() {
GlobalScope.launch {
val client = HttpClient(
{
install(WebSockets) {
}
}
)
println("Starting websocket")
client.webSocket(
method = HttpMethod.Get,
host = "localhost",
port = 8080,
path = "/ws",
request = {
cookie(
name = "user_name",
value = "jetbrains",
expires =
GMTDate(
seconds = 0,
minutes = 0,
hours = 10,
dayOfMonth = 1,
month = Month.APRIL,
year = 2023
)
)
}
) {}
}
}
Indeed this does not send the specified cookie.
It does send all the cookies that are set in the browser session.
Is that a requirement for sending cookies with websocket requests?Aleksei Tirman [JB]
05/30/2022, 6:53 PMJulius
05/30/2022, 6:55 PM