The `utils` module uses a convoluted mechanism for filling byte arrays
with random data. The `generate` function can be used directly, making
the `utils` module obsolete.
`nim-websock` suffered from a number of issues that are being addressed:
1. Long messages > `frameSize` (default 1 MB) were split into fragments
of `frameSize` each. However, when a concurrent message is sent, it
may be interleaved among the fragments of an already-sending message.
This is only allowed for control packets without a mux extension.
2. When the WebSocket session is closed, a msg may have been partially
received. This partial frame was reported as a full message, without
indication that the receiving was canceled. This behaviour is fixed
by raising a `WSClosedError` instead of reporting the partial msg.
3. When an individual `send` operation was canceled, it would actually
stop sending the remainder of a potentially partially sent messages.
This would corrupt the stream for concurrent and followup operations.
Cancellation is now inhibited for the message currently sending.
It is still possible to cancel messages that are not yet scheduled.
4. Messages could get reordered when using asynchronous encoders. This
is addressed by delaying followup messages until the current message
is fully encoded and transmitted (except for control packets).
Co-authored-by: Tanguy <tanguy@status.im>
* don't use global for server instance
* it gets shared between tests and causes gcsafe to trigger
* enable `chronosStrictException` in tests
* avoid asynctests dep
* testcommon -> all_tests (like the other projects)
* validate utf8 at the message level
* move utf-8 validation to message
* rename `recv` to `recvMsg`
* add partial frame validation tests
* use `recvMsg` instead of `recv`
* add support for DNS resolution
- reworked API to be more consistent
- string addresses and Uri types will be now resolved
- made the API more consistent
* log failed connection attempt
* agent string can't contain spaces
* add websock topic (#83)
* style
Co-authored-by: Tanguy Cizain <tanguycizain@gmail.com>
* add accepts api
* Fix partial frame handling and allow extensions to hijack the flow (#56)
* moving files around
* wip
* wip
* move tls example into server example
* add tls functionality
* rename
* rename
* fix tests
* move extension related files to own folder
* use trace instead of debug
* export extensions
* rework partial frame handling and closing
* rework status codes as distincts
* logging
* re-enable extensions processing for frames
* enable all test for non-tls server
* remove tlsserver
* remove offset to mask - don't think we need it
* pass sessions extensions when calling send/recv
* adding encode/decode extensions flow test
* move server/client setup to helpers
* proper frame order execution on decode
* fix tls tests
* fix merge
* add tls support for `accept` call
* fix tests to use accepts & cb
* moving files around
* wip
* wip
* move tls example into server example
* add tls functionality
* rename
* rename
* fix tests
* move extension related files to own folder
* use trace instead of debug
* export extensions
* rework partial frame handling and closing
* rework status codes as distincts
* logging
* re-enable extensions processing for frames
* enable all test for non-tls server
* remove tlsserver
* remove offset to mask - don't think we need it
* pass sessions extensions when calling send/recv
* adding encode/decode extensions flow test
* move server/client setup to helpers
* proper frame order execution on decode
* fix tls tests
* wip
* wip
* move http under ws folder
* use asyctest
* wip
* wip
* rework response sending
* make example work with latest changes
* wip request/response
* misc
* fix example to use new http layer
* pass tls flags to client
* more cleanup
* unused imports
* more unsused imports
* better headers
* add helpre sendError
* export sendError
* attach selected proto to session
* move proto to session
* handle unsupported version
* fix tests
* comment out for now
* fix utf8 tests
* allow tests to be ran in tls
* misc
* use Port type
* add tls flags
* better api
* run tls tests
* fix tests on windows
* allow running tests with tls
* mic
* wip
* fix autobahn ci
* handle close
* cleanup
* logging and error handling
* remove old stream
* implement UTF8 handling
or to be precisely, we add UTF8 validator which main duty
is to detect malformed UTF8 sequence using a fast DFA UTF8
decoder.
also enable autobahn UTF8 category tests, much more green :)
fixes#13
* fixes case 7.5.1 Send a close frame with invalid UTF8 payload
* add tests for validateUTF8
- tests for validateUTF8 in raw mode
- tests for validateUTF8 in websocket client/server
on Windows there is bug with message:
`Unhandled exception: Stream is already closed! [AsyncStreamIncorrectDefect]`
caused by the async stream closed more than once.
* Update http to use chronos http.
* Implement TLS in websocket.
* Add webscoket TLS test.
* Minor nit.
* Add TLS test file.
* Update http to use chronos http. (#6)
* Update http to use chronos http.
* Add stream.nim file.
* Address comments.
* Fix CI failure.
* Minor change.
* Address comments.
* Fix windows CI failing test.
* minor cleanup
* spacess
* more idiomatic connect
* use stew/base10
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
* Implement TLS in websocket.
* Minor nit.
* merge master
* wip
* Update http to use chronos http. (#6)
* Update http to use chronos http.
* Add stream.nim file.
* Address comments.
* Fix CI failure.
* Minor change.
* Address comments.
* Fix windows CI failing test.
* minor cleanup
* spacess
* more idiomatic connect
* use stew/base10
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
* Update http to use chronos http.
* Implement TLS in websocket.
* Minor nit.
* Update http to use chronos http. (#6)
* Update http to use chronos http.
* Add stream.nim file.
* Address comments.
* Fix CI failure.
* Minor change.
* Address comments.
* Fix windows CI failing test.
* minor cleanup
* spacess
* more idiomatic connect
* use stew/base10
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
* Implement TLS in websocket.
* Minor nit.
* add testing keys
* wip
* fix test
* wip
* remove eth dep and add skipdirs
* fix package structure
* fix deps
* check nim version
* Fix CI failure.
* Don't call `ws.stream.closeWait()`
* always close both ends to complete the sequence
* misc
* don't fail on close
* Fix windows CI.
* fix linux x86 builds
* use consistent connect pattern
* move keys to better place
* return dumbResponse
* small cleanup
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
* Use seq[byte] to store data.
* Working bytes conversion.
* Refactor the code.
* Add test.
* Add websocket test and fix closing handshake.
* Add MsgReader to read data in external buffer.
* rework frame reading
* don't do toTitleCase
* fix examples
* use byte for more comfort
* rework message reading + api
* fix tests
* adding specific exception types
* minor cleanup
* fixing tests
* more tests
* check the fin flag at the correct place
* info for debug
* split data not encoded frames
* more tests
* wip - control messages
* closing flow and more explicit exception handling
* test close and pings
* add tests task to nimble
* adding ci
* change recv semantics
* add frame tests
* remove echo
* better frame tests
* fix
* fix
* handle continuation frames properly
* more close logic handling
* wip tests
* handle close reasons properly
* test control frames encoding
* don't pass ws to event callbacks
* fix masking and use correct base64 encoding
* fix ci
* addressing review comments
* fix client example
* i386 ci fix
* wip ci
* fix reading offset
* don't read if socket closed
* fix ci
* wip
* don't read if socket is closed
Co-authored-by: Arijit Das <arijit@status.im>
Co-authored-by: Arijit Das <arijitad.in@gmail.com>
* Implement websocket server.
* Implement websocket client.
* Run nimpretty.
* Remove commented code.
* Address comments.
* Address comments on websocket server.
* Use seq[byte] to store data.
* Working bytes conversion.
* Remove result from return
* Refactor the code.
* Minor change.
* Add test.
* Add websocket test and fix closing handshake.
* Add MsgReader to read data in external buffer.