Commit Graph

683 Commits

Author SHA1 Message Date
Jacek Sieka 075b7abf4c
fix Defect check in non-strict mode (#170) 2021-03-25 15:53:33 +01:00
Kim De Mey c206d2bc19
Add raises annotation to withTimeout callbacks (#168) 2021-03-25 14:20:26 +01:00
Jacek Sieka 4abd7a5645
exception tracking (#166)
* exception tracking

This PR adds minimal exception tracking to chronos, moving the goalpost
one step further.

In particular, it becomes invalid to raise exceptions from `callSoon`
callbacks: this is critical for writing correct error handling because
there's no reasonable way that a user of chronos can possibly _reason_
about exceptions coming out of there: the event loop will be in an
indeterminite state when the loop is executing an _random_ callback.

As expected, there are several issues in the error handling of chronos:
in particular, it will end up in an inconsistent internal state whenever
the selector loop operations fail, because the internal state update
functions are not written in an exception-safe way. This PR turns this
into a Defect, which probably is not the optimal way of handling things
- expect more work to be done here.

Some API have no way of reporting back errors to callers - for example,
when something fails in the accept loop, there's not much it can do, and
no way to report it back to the user of the API - this has been fixed
with the new accept flow - the old one should be deprecated.

Finally, there is information loss in the API: in composite operations
like `poll` and `waitFor` there's no way to differentiate internal
errors from user-level errors originating from callbacks.

* store `CatchableError` in future
* annotate proc's with correct raises information
* `selectors2` to avoid non-CatchableError IOSelectorsException
* `$` should never raise
* remove unnecessary gcsafe annotations
* fix exceptions leaking out of timer waits
* fix some imports
* functions must signal raising the union of all exceptions across all
platforms to enable cross-platform code
* switch to unittest2
* add `selectors2` which supercedes the std library version and fixes
several exception handling issues in there

* fixes

* docs, platform-independent eh specifiers for some functions

* add feature flag for strict exception mode

also bump version to 3.0.0 - _most_ existing code should be compatible
with this version of exception handling but some things might need
fixing - callbacks, existing raises specifications etc.

* fix AsyncCheck for non-void T
2021-03-24 10:08:33 +01:00
Jacek Sieka b964ba2966
Update README (#167) 2021-03-20 08:12:35 +01:00
Eugene Kabanov c8eefb9382
Split HTTPS and HTTP servers. (#165)
* Split HTTPS and HTTP servers.

* Fix review commens
2021-03-17 15:40:40 +02:00
Eugene Kabanov 0b78606e41
Add `server` and `host` headers handling. (#164)
Fix response headers generation to avoid unnecessary computations.
2021-03-11 13:41:13 +02:00
Eugene Kabanov f774644129
Fix integer decoding overflow issue. (#163)
Switch to stew.base10 procedures.
Adjust tests to follow new behavior.
Bump version to 2.6.1.
2021-03-06 00:22:32 +02:00
Andreas Rumpf 1324b2f787
Enable --gc:orc testing for nim-chronos (#161)
* enable --gc:orc testing on nim devel (1.5.x)
2021-03-03 20:04:09 +02:00
cheatfate 1243aef627
Bump chronos version to 2.6.0. 2021-03-02 15:27:42 +02:00
Eugene Kabanov c31e4537fe
Fix contentType handling code. (#162)
Add more respond() aliases.
Add responded() to check if response is already sent.
2021-03-02 15:26:07 +02:00
cheatfate 03707426e4
Remove Travis CI badge and move Github Actions badge. 2021-02-28 00:12:49 +02:00
cheatfate 72151b99cc
Fix `HttpTable.contains` argument requirements. 2021-02-26 11:31:46 +02:00
Eugene Kabanov eb6e32605f
Fix #156 and refactor osnet.nim (#157)
* Refactor osnet.nim to not use `result`.
Fix #156.

* Fix linux compilation error.
2021-02-25 22:04:56 +01:00
cheatfate d6a39e46e1
Fix tests. 2021-02-21 17:34:55 +02:00
cheatfate d595e0dbc6
Send `Content-Length: 0` on error.
Handle `DisconnectError`.
2021-02-21 04:22:59 +02:00
cheatfate 60a53eea99
Fix import/export issue of httputils.
Add bound address to HttpServer object.
2021-02-20 19:41:22 +02:00
Eugene Kabanov d49e0a9c47
Add drop() implementation (was missed) to httpserver and fix transport leak. (#158)
* Add drop() implementation (was missed).
Add tests for drop().
Fix transport leak because of drop().

* Fix future leak.
2021-02-19 14:07:20 +02:00
cheatfate 25688cd0aa Add hexValue tests. 2021-02-18 22:16:04 +02:00
cheatfate 4e9a857b90 Link to original procedure for hexValue(). 2021-02-18 22:16:04 +02:00
cheatfate 1d49ae7a47 Fix x86 int conversion. 2021-02-18 22:16:04 +02:00
cheatfate eb81018d02 Address review comments and fix issues found.
Adding more tests.
2021-02-18 22:16:04 +02:00
cheatfate fc0d1bcb43 Address review comments. 2021-02-18 22:16:04 +02:00
cheatfate 6f8d06f12d Add HttpDisconnectError to avoid client processor notification call. 2021-02-18 22:16:04 +02:00
cheatfate 1789328748 Set TLSStream default to use TLS1.2 only. 2021-02-18 22:16:04 +02:00
cheatfate 3d74c5cdd2 Add tests for getContentEncoding() and getTransferEncoding(). 2021-02-18 22:16:04 +02:00
cheatfate b47fcb3e86 Annotate with `raises:[Defect]`. 2021-02-18 22:16:04 +02:00
cheatfate 45cb009be2 Remove `bodyTimeout` because downloading body is not under our control. 2021-02-18 22:16:04 +02:00
cheatfate 4406ab7072 Add positive decimal integer parsing tests. 2021-02-18 22:16:04 +02:00
cheatfate 3495122867 Fix getMultipartBoundary() issues and add tests for it. 2021-02-18 22:16:04 +02:00
cheatfate 9b48496513 Fix compilation error with nimcrypto/utils import. 2021-02-18 22:16:04 +02:00
cheatfate 3569e4d553 testutils must be last executed test. 2021-02-18 22:16:04 +02:00
cheatfate 3e9ffae407 Properly fix case when request body size exceeds maximum allowed size. 2021-02-18 22:16:04 +02:00
cheatfate 970e5641d7 Add less strict rules for BoundStream reader/writer. 2021-02-18 22:16:04 +02:00
cheatfate d43a9cb92d HttpServer now supports TLS.
Some TLSStream fixes to properly support EOF.
Some HttpServer to properly support TLS handshake problems.
HttpServer test suite for HTTPS.
2021-02-18 22:16:04 +02:00
cheatfate 1a3e9162a4 Fix multipart end of message handling.
Add apps.nim.
Change copyrights dates.
Add httpserver tests to test suite.
2021-02-18 22:16:04 +02:00
cheatfate 789a5f8252 Fix dependency name. 2021-02-18 22:16:04 +02:00
cheatfate fb11d9f8ab Add httptable changes. 2021-02-18 22:16:04 +02:00
cheatfate 8c20b369b7 Fix queryParams() to not produce empty values.
Fix part() cancellation.
Add requestInfo() procedure.
Fix request.scheme.
Add MultiPart.isEmpty()
Fix MultiPart counter.
Add isEmpty() for HttpTable.
Add some documentation in HttpTable.
2021-02-18 22:16:04 +02:00
cheatfate a310a5620a General fixes. 2021-02-18 22:16:04 +02:00
cheatfate 0b03f8ec50 Expect header handling and response preparations. 2021-02-18 22:16:04 +02:00
cheatfate 74b0f85fc7 Add async post() procedure. 2021-02-18 22:16:04 +02:00
cheatfate 53aec163eb Fix nimble dependencies. 2021-02-18 22:16:04 +02:00
cheatfate 475c03ff7b Fix MultiPart handling mechanisms. 2021-02-18 22:16:04 +02:00
cheatfate c0472bd349 Fix streams to check only for Closed state. 2021-02-18 22:16:04 +02:00
cheatfate 534df03a0b Fixes and improvements 2021-02-18 22:16:04 +02:00
cheatfate 0e5ea5b737 Prepare for HttpResponse. 2021-02-18 22:16:04 +02:00
cheatfate 60e5396a9e Remove executable. 2021-02-18 22:16:04 +02:00
cheatfate 8381a40868 Initial commit. 2021-02-18 22:16:04 +02:00
cheatfate 0b396c34d8 Add newline. 2021-02-18 22:16:04 +02:00
cheatfate 2defc4b822 Add sequence of bytes as boundary to BoundStream and tests. 2021-02-18 22:16:04 +02:00