Skip to content

Commit

Permalink
Merge pull request #96 from guzba/ryan
Browse files Browse the repository at this point in the history
0.3.5
  • Loading branch information
guzba authored Oct 29, 2023
2 parents 6ed6dc3 + 592233e commit 4931839
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion mummy.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "0.3.4"
version = "0.3.5"
author = "Ryan Oldenburg"
description = "Multithreaded HTTP + WebSocket server"
license = "MIT"
Expand Down
7 changes: 4 additions & 3 deletions src/mummy/internal.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import common, std/nativesockets, webby/httpheaders
import common, std/nativesockets, webby/httpheaders, std/endians

template currentExceptionAsMummyError*(): untyped =
let e = getCurrentException()
Expand Down Expand Up @@ -31,9 +31,10 @@ proc encodeFrameHeader*(
copyMem(result[result.len - 2].addr, l.addr, 2)
else:
result.add 127.char
var l = cast[uint32](payloadLen).htonl
var l: uint64
bigEndian64(l.addr, payloadLen.unsafeAddr)
result.setLen(result.len + 8)
copyMem(result[result.len - 4].addr, l.addr, 4)
copyMem(result[result.len - 8].addr, l.addr, 8)

proc encodeHeaders*(
statusCode: int,
Expand Down
10 changes: 7 additions & 3 deletions tests/test_websockets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ proc websocketHandler(
doAssert message.data == ""
of mummy.Pong:
doAssert false
websocket.send("Fifth", mummy.BinaryMessage)
var fifth: string
for i in 0 ..< 0xffff + 1:
fifth.add 'a'
websocket.send(fifth, mummy.BinaryMessage)
of ErrorEvent:
discard
of CloseEvent:
Expand All @@ -61,8 +64,9 @@ proc requesterProc() =
ws.send("Third")
ws.send("Fourth", whisky.BinaryMessage)
ws.send("", whisky.Ping)
doAssert ws.receiveMessage() ==
some(whisky.Message(kind: whisky.BinaryMessage, data: "Fifth"))
let fifth = ws.receiveMessage()
doAssert fifth.get.kind == whisky.BinaryMessage
doAssert fifth.get.data.len == 0xffff + 1
ws.close()

echo "Done, shut down the server"
Expand Down

0 comments on commit 4931839

Please sign in to comment.