Add HttpDisconnectError to avoid client processor notification call.
This commit is contained in:
parent
1789328748
commit
6f8d06f12d
|
@ -25,6 +25,7 @@ type
|
|||
code*: HttpCode
|
||||
HttpRecoverableError* = object of HttpError
|
||||
code*: HttpCode
|
||||
HttpDisconnectError* = object of HttpError
|
||||
|
||||
TransferEncodingFlags* {.pure.} = enum
|
||||
Identity, Chunked, Compress, Deflate, Gzip
|
||||
|
@ -80,6 +81,11 @@ proc newHttpRecoverableError*(msg: string,
|
|||
tre.code = code
|
||||
tre
|
||||
|
||||
proc newHttpDisconnectError*(): ref HttpDisconnectError {.
|
||||
raises: [HttpDisconnectError].} =
|
||||
var tre = newException(HttpDisconnectError, "Remote peer disconnected")
|
||||
tre
|
||||
|
||||
iterator queryParams*(query: string): tuple[key: string, value: string] {.
|
||||
raises: [Defect].} =
|
||||
## Iterate over url-encoded query string.
|
||||
|
|
|
@ -429,10 +429,8 @@ proc getRequest(conn: HttpConnectionRef): Future[HttpRequestRef] {.async.} =
|
|||
raise newHttpCriticalError("Invalid request received", res.error)
|
||||
else:
|
||||
return res.get()
|
||||
except AsyncStreamIncompleteError:
|
||||
raise newHttpCriticalError("Remote peer disconnected")
|
||||
except AsyncStreamReadError:
|
||||
raise newHttpCriticalError("Connection with remote peer has been lost")
|
||||
except AsyncStreamIncompleteError, AsyncStreamReadError:
|
||||
raise newHttpDisconnectError()
|
||||
except AsyncStreamLimitError:
|
||||
raise newHttpCriticalError("Maximum size of request headers reached",
|
||||
Http413)
|
||||
|
@ -561,6 +559,9 @@ proc processLoop(server: HttpServerRef, transp: StreamTransport) {.async.} =
|
|||
let error = HttpProcessError.init(HTTPServerError.CriticalError, exc,
|
||||
transp.remoteAddress(), exc.code)
|
||||
arg = RequestFence[HttpRequestRef].err(error)
|
||||
except HttpDisconnectError:
|
||||
# If remote peer disconnected we just exiting loop
|
||||
breakLoop = true
|
||||
except CatchableError as exc:
|
||||
let error = HttpProcessError.init(HTTPServerError.CatchableError, exc,
|
||||
transp.remoteAddress(), Http500)
|
||||
|
|
Loading…
Reference in New Issue