Commit Graph

228 Commits

Author SHA1 Message Date
Eugene Kabanov 59b91bf0ca
Add more helpers to handle Accept header. (#224)
* Add API working with strings instead of `HttpRequestRef` object.

* Fix comment.
2021-09-28 01:41:29 +03:00
Eugene Kabanov 80102a3b6a
Eventbus implementation (#214)
* Initial commit.

* Move AsyncEventBus implementation to asyncsync.nim
Add subscriptAll(), waitAllEvents() primitives.
Add emitWait() primitive.
Add emitter source location implementation.
Add tests.
2021-09-15 16:55:15 +03:00
Eugene Kabanov bbbcb55493
Server-side events implementation. (#222)
Fix keep-alive issue.
Refactor some prepareXXX routines.
2021-09-14 20:32:58 +03:00
Eugene Kabanov 5034f0a5a6
Fix issue #219 (#220)
* Address issue #219 and add tests for it.
Some cosmetic refactoring.

* Fix *nix tests.
2021-09-05 00:53:27 +03:00
Eugene Kabanov 05c91418be
Export async-related imports to allow partial imports. (#218) 2021-08-26 14:22:29 +03:00
Eugene Kabanov 9d80c7068f
Server must not send `Host` header. (#215) 2021-08-15 04:29:48 +03:00
Eugene Kabanov b14f66c295
No more Defect on stream close. (#213)
Fix async streams issue with replacing state.
Add `closing` states to HTTP's server connection, request and bodyrw.
Fix Http server cancellation leaks.
2021-08-06 13:13:55 +03:00
Eugene Kabanov ef2430d08d
Add `Accept` header handling to httpserver.nim. (#211)
* Add `Accept` header handling to httpserver.nim.
Add simple test suite.
Bump version to 3.0.6.

* Fix compilation error.
2021-07-28 17:08:38 +03:00
Johann Bauer 3a9cc6bfc9
Update `toIPv4` and `toIPv6` to keep the port (#209)
Currently, converting a `TransportAddress` from IPv4 to IPv6 or vice-versa will set the port to 0.
2021-07-27 14:39:48 +03:00
Eugene Kabanov 14ebf269e9
Fix accept defect (#206)
* Fix accept() FutureDefect on cancellation.

* Do not close pipe twice.

* Check for retFuture state before changing it state.
2021-06-30 18:22:37 +03:00
Eugene Kabanov 15137f71c3
Basic authorization implementation for HTTP client. (#204)
* Basic authorization implementation for HTTP client.
Add tests for basic authorization.

* Bump chronos version to 3.0.5.
2021-06-29 02:38:08 +03:00
Eugene Kabanov f7dd6b76c2
Safely close connection's streams. (#199) 2021-06-14 15:16:33 +03:00
Eugene Kabanov e6fd38fd49
Add one more state `Closing` to help avoid race condition while in `closeWait` of request, response, connection. (#198) 2021-06-10 13:58:41 +03:00
Eugene Kabanov 7ccb170f7a
Enable comma as array delimiter and adding tests. (#191)
* Enable comma as array delimiter and adding tests.

* Bump version to 3.0.4.
2021-05-17 22:39:24 +03:00
cheatfate 67f0f1224f
Bump nimble version.
Make some useful fields public.
2021-05-10 10:40:56 +03:00
Eugene Kabanov be184a815c
Httpclient (#182)
* Initial commit.

* Some refactoring.

* Allow boundstream to accept uint64.
Fix httpserver and asyncstream tests to follow new uint64 requirement.

* send() and getBodyBytes() implementations.

* Add closeWait for response and request.
Refactor finish/close flow.

* Changes in state machine
Add first test.

* Missing test file.

* Fixed tests
Add http leaking trackers and tests.

* Some fixes in multipart.
Fix automatic Content-Length header for requests with body.
Fix getBodyBytes() assertions.
Merging tests to main suite.

* Post rebase fixes.

* Fix tests big message generation.

* Fix response state management and leaks for getBodyXXX() procedures.

* Add redirection support to client and server.
Add fetch(url) procedure with redirection support.
Add tests for redirection.
2021-05-10 10:26:36 +03:00
Eugene Kabanov d270dba8a3
Fix unused warnings, result, asyncCheck and 80 cpl (#185)
* Fix sources to follow 80 characters per line.
Fix unused compilation warnings.
Refactor (remove result) handles.nim.
Fix tests to use asyncSpawn instead of asyncCheck.

* Fix handles for Unix platforms.
2021-05-07 23:52:24 +03:00
Eugene Kabanov fed6b0ac92
Restore functionality of zero-sized bounded reader/writer streams. (#184)
* Restore functionality of zero-sized bounded reader/writer streams.
Adding tests for it.

* run build_nim.sh unconditionally

Co-authored-by: Ștefan Talpalaru <stefantalpalaru@yahoo.com>
2021-05-07 18:52:44 +03:00
Ștefan Talpalaru c15c985c1f
support nimStackTraceOverride (#181) 2021-05-06 09:49:55 +02:00
Jacek Sieka 43b8aada20
Add message to task failure message (#183) 2021-05-06 09:46:58 +02:00
cheatfate 645d62db78
Remove fastpath execution and finally fix issue. 2021-04-27 00:07:49 +03:00
Eugene Kabanov 39f4060e07
Refactor and optimization of BoundedStream. (#180)
Documentation for BoundedStream.
Fix HttpServer bounding.
2021-04-26 14:05:37 +03:00
Eugene Kabanov 833d968782
Fix upload() issue and adding tests. (#179) 2021-04-24 20:32:21 +03:00
Eugene Kabanov e6ba00cb81
Fix reading could stuck on very big chunked headers and tests. (#178) 2021-04-22 15:32:28 +03:00
Eugene Kabanov aab1e30a72
Refactor common.nim and add more resolve procedures. (#177)
* Refactor common.nim to remove `result` usage.
Fix comparison of TransportAddress issue.
Add resolveTAddress procedures for both IPv4 and IPv6 addresses.
Fix tests.

* Bump version to 3.0.2.
2021-04-10 00:39:54 +03:00
Jacek Sieka 895fc53193
add explicit gcsafe annotations (fixes #174) (#175)
Seems like a variation of https://github.com/nim-lang/Nim/issues/17369
2021-04-03 10:05:08 +02:00
markspanbroek e5d3ecdd01
Ensures that asyncmacro2 does not raise exceptions (#172)
* Ensures that asyncmacro2 does not raise exceptions

* Remove unnecessary include
2021-03-30 16:48:20 +02:00
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
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
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 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 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