Skip to content

Bad close codes#36

Merged
ianpartridge merged 6 commits intomasterfrom
badCloseCodes
Apr 16, 2018
Merged

Bad close codes#36
ianpartridge merged 6 commits intomasterfrom
badCloseCodes

Conversation

@Andrew-Lees11
Copy link
Copy Markdown
Contributor

Pull request to make our web sockets pass autobahn tests 7.* regarding close codes.

reserved user close codes (1005, 1006) and undefined codes < 3000 will now return a protocol error.

Close payloads can now not be longer than 125 bytes or equal to 1 byte as defined by the protocol

The close code provided by the server is now used to be sent back instead of just calculating it and then sending back .normal regardless.

Two Tests have been added and an existing test ha been change to check for the desired behavior.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Apr 16, 2018

Codecov Report

Merging #36 into master will increase coverage by 0.21%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #36      +/-   ##
==========================================
+ Coverage   92.12%   92.33%   +0.21%     
==========================================
  Files           9        9              
  Lines         495      496       +1     
==========================================
+ Hits          456      458       +2     
+ Misses         39       38       -1
Flag Coverage Δ
#KituraWebSocket 92.33% <83.33%> (+0.21%) ⬆️
Impacted Files Coverage Δ
...ces/KituraWebSocket/WebSocketCloseReasonCode.swift 50% <100%> (+8.62%) ⬆️
Sources/KituraWebSocket/WebSocketConnection.swift 92.22% <75%> (-0.52%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a8b470...3a2817c. Read the comment docs.

case 1011: return .serverError
default:
return .userDefined(reasonCode)
if(reasonCode < 3000) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove parentheses.

} else if frame.payload.length == 0 {
reasonCode = .normal
} else {
connectionClosed(reason: .protocolError, description: "Close frames, which contain a payload, must be between 2 an 125 octets inclusive")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an/and

let expectedPayload = NSMutableData()
var part = self.payload(closeReasonCode: .protocolError)
expectedPayload.append(part.bytes, length: part.length)
part = self.payload(text: "Close frames, which contain a payload, must be between 2 an 125 octets inclusive")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an/and

@ianpartridge ianpartridge merged commit 5eaae44 into master Apr 16, 2018
@ianpartridge ianpartridge deleted the badCloseCodes branch April 16, 2018 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants