Closed Bug 674716 Opened 13 years ago Closed 13 years ago

Update WebSocket API to latest draft - close codes and reasons

Categories

(Core :: Networking: WebSockets, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla8

People

(Reporter: mcmanus, Assigned: mcmanus)

References

Details

(Keywords: dev-doc-complete, Whiteboard: [inbound])

Attachments

(1 file, 3 obsolete files)

our closeEvent is missing the code and reason attributes, additionally the close method (for sending closes) is missing the same optional stuff. The protocol defines a number of standard reason codes.
Blocks: 666349
No longer depends on: 666349, 674527
Attached patch patch v1 (obsolete) — Splinter Review
includes tests.. :sicking r? for dom, I'll add a r? biesi for the network side
Assignee: nobody → mcmanus
Status: NEW → ASSIGNED
Attachment #548926 - Flags: review?(jonas)
Attachment #548926 - Flags: review?(cbiesinger)
Attached patch patch v2 (obsolete) — Splinter Review
try server showed me that v1 didn't build on windows due to an extra const. That's the only change.
Attachment #548926 - Attachment is obsolete: true
Attachment #548926 - Flags: review?(jonas)
Attachment #548926 - Flags: review?(cbiesinger)
Attachment #549008 - Flags: review?(jonas)
Attachment #549008 - Flags: review?(cbiesinger)
Blocks: 674890
No longer blocks: 674890
Blocks: 674905
No longer blocks: 674905
Comment on attachment 549008 [details] [diff] [review] patch v2 Review of attachment 549008 [details] [diff] [review]: ----------------------------------------------------------------- ::: content/base/src/nsWebSocket.cpp @@ +835,5 @@ > > rv = conn->Init(this); > mConnection = conn; > if (NS_FAILED(rv)) { > + Close(0, NS_LITERAL_STRING(""), 0); EmptyString() ::: netwerk/protocol/websocket/WebSocketChannelParent.cpp @@ +87,5 @@ > > rv = mChannel->SetNotificationCallbacks(this); > if (NS_FAILED(rv)) { > + mChannel->Close(nsIWebSocketChannel::CLOSE_ABNORMAL, > + NS_LITERAL_CSTRING("")); EmptyString() here and on the other lines
Attachment #549008 - Flags: review?(cbiesinger) → review+
Comment on attachment 549008 [details] [diff] [review] patch v2 Review of attachment 549008 [details] [diff] [review]: ----------------------------------------------------------------- r=me with that fixed. ::: content/base/src/nsWebSocket.cpp @@ +1306,5 @@ > + if (NS_IS_HIGH_SURROGATE(aData[i])) { > + if (i + 1 == length || !NS_IS_LOW_SURROGATE(aData[i + 1])) { > + return PR_TRUE; > + } > + ++i; Nit: Slightly faster as: ++i; if (i == length || !NS_IS_LOW_SURROGATE(aData[i])) { ... @@ +1352,5 @@ > + } > + > + if (argc >= 2) { > + if (ContainsUnpairedSurrogates(reason)) > + return NS_ERROR_DOM_SYNTAX_ERR; Hmm.. If we bail here end up setting mClientReasonCode and possibly reusing it on a later call to close() which seems wrong. @@ +1358,5 @@ > + CopyUTF16toUTF8(reason, mClientReason); > + > + // The API requires the UTF-8 string to be 123 or less bytes > + if (mClientReason.Length() > 123) > + return NS_ERROR_DOM_SYNTAX_ERR; Same here but with both mClientReason and mClientReasonCode set. We should probably set any of them if all checks pass. Also please add a test that catches this.
Attachment #549008 - Flags: review?(jonas) → review+
Attached patch patch 3 (obsolete) — Splinter Review
review comments incorporated .. seeking sr due to API change
Attachment #549008 - Attachment is obsolete: true
Attachment #550393 - Flags: superreview?
Attachment #550393 - Flags: review+
Comment on attachment 550393 [details] [diff] [review] patch 3 that new test I added at jonas's request isn't quite right upon further reflection.. I'll update and re sr?
Attachment #550393 - Flags: superreview?
Attached patch v4Splinter Review
Attachment #550393 - Attachment is obsolete: true
Attachment #550397 - Flags: superreview?(bzbarsky)
Attachment #550397 - Flags: review+
Attachment #550397 - Flags: superreview?(bzbarsky) → superreview+
Whiteboard: [inbound]
Target Milestone: --- → mozilla8
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: