Some more conversion of tab to spaces and doc update.
This commit is contained in:
parent
073521d37d
commit
c5d21f4cef
@ -36,13 +36,10 @@ import io.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
|||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Safari 5+ (draft-ietf-hybi-thewebsocketprotocol-00)
|
* <li>Safari 5+ (draft-ietf-hybi-thewebsocketprotocol-00)
|
||||||
* <li>
|
|
||||||
* <li>Chrome 6-13 (draft-ietf-hybi-thewebsocketprotocol-00)
|
* <li>Chrome 6-13 (draft-ietf-hybi-thewebsocketprotocol-00)
|
||||||
* <li>
|
|
||||||
* <li>Chrome 14+ (draft-ietf-hybi-thewebsocketprotocol-10)
|
* <li>Chrome 14+ (draft-ietf-hybi-thewebsocketprotocol-10)
|
||||||
* <li>
|
* <li>Chrome 16+ (RFC 6455 aka draft-ietf-hybi-thewebsocketprotocol-17)
|
||||||
* <li>Firefox 7+ (draft-ietf-hybi-thewebsocketprotocol-10)
|
* <li>Firefox 7+ (draft-ietf-hybi-thewebsocketprotocol-10)
|
||||||
* <li>
|
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public class WebSocketSslServer {
|
public class WebSocketSslServer {
|
||||||
|
@ -38,41 +38,41 @@ import org.junit.Test;
|
|||||||
|
|
||||||
public class WebSocketServerHandshaker13Test {
|
public class WebSocketServerHandshaker13Test {
|
||||||
|
|
||||||
private DefaultChannelPipeline createPipeline() {
|
private DefaultChannelPipeline createPipeline() {
|
||||||
DefaultChannelPipeline pipeline = new DefaultChannelPipeline();
|
DefaultChannelPipeline pipeline = new DefaultChannelPipeline();
|
||||||
pipeline.addLast("chunkAggregator", new HttpChunkAggregator(42));
|
pipeline.addLast("chunkAggregator", new HttpChunkAggregator(42));
|
||||||
pipeline.addLast("requestDecoder", new HttpRequestDecoder());
|
pipeline.addLast("requestDecoder", new HttpRequestDecoder());
|
||||||
pipeline.addLast("responseEncoder", new HttpResponseEncoder());
|
pipeline.addLast("responseEncoder", new HttpResponseEncoder());
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPerformOpeningHandshake() {
|
public void testPerformOpeningHandshake() {
|
||||||
Channel channelMock = EasyMock.createMock(Channel.class);
|
Channel channelMock = EasyMock.createMock(Channel.class);
|
||||||
|
|
||||||
DefaultChannelPipeline pipeline = createPipeline();
|
DefaultChannelPipeline pipeline = createPipeline();
|
||||||
EasyMock.expect(channelMock.getPipeline()).andReturn(pipeline);
|
EasyMock.expect(channelMock.getPipeline()).andReturn(pipeline);
|
||||||
|
|
||||||
// capture the http response in order to verify the headers
|
// capture the http response in order to verify the headers
|
||||||
Capture<HttpResponse> res = new Capture<HttpResponse>();
|
Capture<HttpResponse> res = new Capture<HttpResponse>();
|
||||||
EasyMock.expect(channelMock.write(capture(res))).andReturn(new DefaultChannelFuture(channelMock, true));
|
EasyMock.expect(channelMock.write(capture(res))).andReturn(new DefaultChannelFuture(channelMock, true));
|
||||||
|
|
||||||
replay(channelMock);
|
replay(channelMock);
|
||||||
|
|
||||||
HttpRequest req = new DefaultHttpRequest(HTTP_1_1, HttpMethod.GET, "/chat");
|
HttpRequest req = new DefaultHttpRequest(HTTP_1_1, HttpMethod.GET, "/chat");
|
||||||
req.setHeader(Names.HOST, "server.example.com");
|
req.setHeader(Names.HOST, "server.example.com");
|
||||||
req.setHeader(Names.UPGRADE, WEBSOCKET.toLowerCase());
|
req.setHeader(Names.UPGRADE, WEBSOCKET.toLowerCase());
|
||||||
req.setHeader(Names.CONNECTION, "Upgrade");
|
req.setHeader(Names.CONNECTION, "Upgrade");
|
||||||
req.setHeader(Names.SEC_WEBSOCKET_KEY, "dGhlIHNhbXBsZSBub25jZQ==");
|
req.setHeader(Names.SEC_WEBSOCKET_KEY, "dGhlIHNhbXBsZSBub25jZQ==");
|
||||||
req.setHeader(Names.SEC_WEBSOCKET_ORIGIN, "http://example.com");
|
req.setHeader(Names.SEC_WEBSOCKET_ORIGIN, "http://example.com");
|
||||||
req.setHeader(Names.SEC_WEBSOCKET_PROTOCOL, "chat, superchat");
|
req.setHeader(Names.SEC_WEBSOCKET_PROTOCOL, "chat, superchat");
|
||||||
req.setHeader(Names.SEC_WEBSOCKET_VERSION, "13");
|
req.setHeader(Names.SEC_WEBSOCKET_VERSION, "13");
|
||||||
|
|
||||||
WebSocketServerHandshaker13 handsaker13 = new WebSocketServerHandshaker13("ws://example.com/chat", "chat",
|
WebSocketServerHandshaker13 handsaker13 = new WebSocketServerHandshaker13("ws://example.com/chat", "chat",
|
||||||
false);
|
false);
|
||||||
handsaker13.performOpeningHandshake(channelMock, req);
|
handsaker13.performOpeningHandshake(channelMock, req);
|
||||||
|
|
||||||
Assert.assertEquals("s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", res.getValue().getHeader(Names.SEC_WEBSOCKET_ACCEPT));
|
Assert.assertEquals("s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", res.getValue().getHeader(Names.SEC_WEBSOCKET_ACCEPT));
|
||||||
Assert.assertEquals("chat", res.getValue().getHeader(Names.SEC_WEBSOCKET_PROTOCOL));
|
Assert.assertEquals("chat", res.getValue().getHeader(Names.SEC_WEBSOCKET_PROTOCOL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user