* Fixes.
* Make httpcommon no-raises.
* Make httpbodyrw no-raises.
* Make multipart no-raises.
* Make httpdebug no-raises.
* Make httpagent no-raises.
* Make httpclient no-raises.
* Make httpserver/shttpserver no-raises.
* fix prepend/remove when E is noraises
---------
Co-authored-by: Jacek Sieka <jacek@status.im>
* Add callTick and stream cancellation tests.
* Fix stepsAsync() test.
* Cancellation changes.
* Update and add more cancellation tests.
* Fix Posix shutdown call to handle ENOTCONN error.
* With new changes to to cancellation its now possible.
* Refactor testsoon.nim to not produce artifacts after tests are finished.
* Debugging MacOS issue.
* Adjust flaky test times.
* Fix issue.
* Add test for issue #334 which was also addressed in this PR.
Avoid `break` in problematic test.
* Add noCancelWait() call which prohibits cancellation.
Fix closeWait() calls to use noCancelWait() predicate.
Adding sleep to flaky MacOS test.
* Remove all debugging echoes.
* Fix cancelAndWait() which now could perform multiple attempts to cancel target Future (mustCancel behavior).
* Fix issues revealed by switch to different cancelAndWait().
* Address review comments.
* Fix testutils compilation warning.
* Rename callTick() to internalCallTick().
* Add some documentation comments.
* Disable flaky ratelimit test.
* Rename noCancelWait() to noCancel().
Address review comments.
* Refactor chronos trackers to be more simple.
* Refactor trackers.
Add HTTP server trackers.
Refactor HTTP main processing loop.
* Compatibility fixes.
Add checkLeaks().
* Fix posix test issue.
* Add httpdebug module which introduces HTTP connection dumping helpers.
Add tests for it.
* Recover and deprecate old version of Trackers.
* Make public iterators to iterate over all tracker counters available.
Fix asynctests to use public iterators instead private one.
* Tentative fix for the HTTP client connection state assertion failures
I've traced the problem to a HTTP connection being closed while there
are outstanding requests that still go through the motions (the crash
occurs when a requests reaches its `finish` processing step, but it
was already put in a Closed state by the connection that owns it).
* Use distinct error exception instead of cancellation error.
Co-authored-by: cheatfate <eugene.kabanov@status.im>
When calling the HTTP `send` / `open` functions, `acquireConnection` is
called to obtain a connection in state `Ready`. In the next code block,
the connection state is advanced to `RequestHeadersSending`. However,
returning from chronos `async` procs yields control, similar to `await`.
This means that a connection may be added to the pool in `Ready` state,
and then a different `acquireConnection` call may obtain a second ref.
Introducing a new `Acquired` state ensures consistency in this case.
No tests added due to this being scheduler dependent; ran manual tests
by adding a `doAssert item.state != HttpClientConnectionState.Acquired`
between `if not(isNil(conn)):` and `return conn`. Eventually, the assert
got hit after several hours of repeated tests, confirming the edge case
to be solved by applying this fix.
Not sure if it is by design that returning from an `async` proc yields.
Even if it's not, this should solve current HTTP issues in nimbus-eth2.
Fix async streams issue with replacing state.
Add `closing` states to HTTP's server connection, request and bodyrw.
Fix Http server cancellation leaks.
* 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.