2021-06-27 06:37:33 +00:00
|
|
|
<img alt="Websock Logo" align="left" src="websock.svg" width="15%"/>
|
|
|
|
|
2020-12-08 10:15:21 +00:00
|
|
|
# Websocket for Nim
|
2020-12-01 12:43:59 +00:00
|
|
|
|
2021-06-27 06:37:33 +00:00
|
|
|
![Github action](https://github.com/status-im/nim-websock/workflows/CI/badge.svg)
|
2021-05-21 02:13:09 +00:00
|
|
|
|
2021-06-20 03:17:05 +00:00
|
|
|
This is an implementation of [Websocket](https://tools.ietf.org/html/rfc6455) protocol for
|
2021-06-27 06:37:33 +00:00
|
|
|
[Nim](https://nim-lang.org/). nim-websock have both client and server in regular ws and wss(secure) mode.
|
2021-05-21 09:45:26 +00:00
|
|
|
|
2021-06-27 06:37:33 +00:00
|
|
|
It also pass all autobahn tests [Autobahn summary report](https://status-im.github.io/nim-websock/).
|
2021-05-21 09:45:26 +00:00
|
|
|
|
2021-04-06 12:51:14 +00:00
|
|
|
Building and testing
|
2020-12-01 12:43:59 +00:00
|
|
|
--------------------
|
|
|
|
|
|
|
|
Install dependencies:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
nimble install -d
|
|
|
|
```
|
|
|
|
|
2020-12-08 10:15:21 +00:00
|
|
|
Starting HTTP server:
|
2020-12-01 12:43:59 +00:00
|
|
|
|
|
|
|
```bash
|
2021-06-27 06:37:33 +00:00
|
|
|
nim c -r examples/server.nim
|
2020-12-08 10:15:21 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Testing Server Response:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
curl --location --request GET 'http://localhost:8888'
|
2020-12-01 12:43:59 +00:00
|
|
|
```
|
2020-12-08 12:49:22 +00:00
|
|
|
|
|
|
|
Testing Websocket Handshake:
|
|
|
|
```bash
|
|
|
|
curl --include \
|
|
|
|
--no-buffer \
|
|
|
|
--header "Connection: Upgrade" \
|
|
|
|
--header "Upgrade: websocket" \
|
|
|
|
--header "Host: example.com:80" \
|
|
|
|
--header "Origin: http://example.com:80" \
|
|
|
|
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
|
|
|
|
--header "Sec-WebSocket-Version: 13" \
|
|
|
|
http://localhost:8888/ws
|
|
|
|
```
|
2021-04-06 12:51:14 +00:00
|
|
|
|
|
|
|
## Roadmap
|
|
|
|
|
|
|
|
- [x] Framing
|
|
|
|
- [x] Text Messages
|
|
|
|
- [x] Binary Messages
|
|
|
|
- [x] Pings/Pongs
|
|
|
|
- [x] Reserved Bits
|
|
|
|
- [x] Opcodes
|
|
|
|
- [x] Non-control Opcodes
|
|
|
|
- [x] Control Opcodes
|
|
|
|
- [x] Fragmentation
|
2021-06-20 03:17:05 +00:00
|
|
|
- [x] UTF-8 Handling
|
2021-04-06 12:51:14 +00:00
|
|
|
- [x] Close Handling
|
|
|
|
- [x] Basic close behavior
|
|
|
|
- [x] Close frame structure
|
|
|
|
- [x] Payload length
|
|
|
|
- [x] Valid close codes
|
|
|
|
- [x] Invalid close codes
|
2021-06-20 03:17:05 +00:00
|
|
|
- [x] Integrate Autobahn Test suite.
|
|
|
|
- [x] WebSocket Compression
|
|
|
|
- [x] WebSocket Extensions
|
2021-04-06 12:51:14 +00:00
|
|
|
- [ ] Performance
|