Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ All notable changes to this project will be documented in this file. Changes not
## Fixed
- An issue in the `HttpRouter` causing issues to handle routes with overlapping in the tail. ([#379](https://github.com/httpswift/swifter/pull/359), [#382](https://github.com/httpswift/swifter/pull/382)) by [@Vkt0r](https://github.com/Vkt0r)

## Changed
- Performance: Batch reads of websocket payloads rather than reading byte-by-byte. ([#387](https://github.com/httpswift/swifter/pull/387)) by [@lynaghk](https://github.com/lynaghk)


# [1.4.6]
## Added
- The `.movedTemporarily` case (HTTP 307) to possibles HTTP responses. ([#352](https://github.com/httpswift/swifter/pull/352)) by [@csch](https://github.com/csch)
Expand Down
5 changes: 4 additions & 1 deletion Sources/WebSockets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,12 @@ public class WebSocketSession: Hashable, Equatable {
let b7 = UInt64(try socket.read())
len = UInt64(littleEndian: b0 | b1 | b2 | b3 | b4 | b5 | b6 | b7)
}

let mask = [try socket.read(), try socket.read(), try socket.read(), try socket.read()]
//Read payload all at once, then apply mask (calling `socket.read` byte-by-byte is super slow).
frm.payload = try socket.read(length: Int(len))
for i in 0..<len {
frm.payload.append(try socket.read() ^ mask[Int(i % 4)])
frm.payload[Int(i)] ^= mask[Int(i % 4)]
}
return frm
}
Expand Down