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