Closed Egorand closed 7 years ago
It may have been changed after running the autobahn test suite. Doss the commit history offer any answers? I can look later otherwise.
On Sat, Aug 19, 2017, 5:24 PM Egor Andreevici notifications@github.com wrote:
In the Javadoc for WebSocket.close():
@param code Status code as defined by Section 7.4 of RFC 6455 or {@code 0}.
When called with the following args:
webSocket.close(0, "Bye!");
It throws:
java.lang.IllegalArgumentException: Code must be in range [1000,5000): 0
at okhttp3.internal.ws.WebSocketProtocol.validateCloseCode(WebSocketProtocol.java:120) at okhttp3.internal.ws.RealWebSocket.close(RealWebSocket.java:399) at okhttp3.internal.ws.RealWebSocket.close(RealWebSocket.java:395)
It's not clear what 0 would mean anyway, the RFC https://tools.ietf.org/html/rfc6455#section-7.4.2 states that this code is not used. Does it make sense to just fix the Javadoc?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/square/okhttp/issues/3531, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEES8B5GY_HQxwsL0rE3aRqZKrCMoCks5sZ1KagaJpZM4O8clm .
I found c8dbcce that adds validateCloseCode(code)
to close()
WebSocketWriter handles this and tests expect it
if (code != 0) {
validateCloseCode(code);
}
@Test public void clientEmptyClose() throws IOException {
clientWriter.writeClose(0, null);
assertData("888060b420bb");
}
I think we agreed to just change the docs https://github.com/square/okhttp/pull/3540
In the Javadoc for
WebSocket.close()
:When doing the following:
It throws:
It's not clear what
0
would mean anyway, the RFC states that this code is not used. Does it make sense to just fix the Javadoc?