Let asynchttpserver pass control of socket to cb for upgrades.
This commit is contained in:
parent
b33fbedec0
commit
9df1704aa1
1 changed files with 4 additions and 2 deletions
|
|
@ -28,8 +28,7 @@
|
||||||
import tables, asyncnet, asyncdispatch, parseutils, uri, strutils
|
import tables, asyncnet, asyncdispatch, parseutils, uri, strutils
|
||||||
import httpcore
|
import httpcore
|
||||||
|
|
||||||
export HttpHeaders, httpcore.`[]`, httpcore.`[]=`, httpcore.add, httpcore.`==`,
|
export httpcore except parseHeader
|
||||||
httpcore.HttpCode, httpcore.HttpVersion, httpcore.toString
|
|
||||||
|
|
||||||
# TODO: If it turns out that the decisions that asynchttpserver makes
|
# TODO: If it turns out that the decisions that asynchttpserver makes
|
||||||
# explicitly, about whether to close the client sockets or upgrade them are
|
# explicitly, about whether to close the client sockets or upgrade them are
|
||||||
|
|
@ -186,6 +185,9 @@ proc processClient(client: AsyncSocket, address: string,
|
||||||
await request.respond(Http400, "Invalid request method. Got: " &
|
await request.respond(Http400, "Invalid request method. Got: " &
|
||||||
request.reqMethod)
|
request.reqMethod)
|
||||||
|
|
||||||
|
if "upgrade" in request.headers.getOrDefault("connection"):
|
||||||
|
return
|
||||||
|
|
||||||
# Persistent connections
|
# Persistent connections
|
||||||
if (request.protocol == HttpVer11 and
|
if (request.protocol == HttpVer11 and
|
||||||
request.headers.getOrDefault("connection").normalize != "close") or
|
request.headers.getOrDefault("connection").normalize != "close") or
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue