use of org.eclipse.jetty.websocket.common.test.BlockheadServer in project jetty.project by eclipse.
the class ClientCloseTest method startServer.
@Before
public void startServer() throws Exception {
server = new BlockheadServer();
server.start();
}
use of org.eclipse.jetty.websocket.common.test.BlockheadServer in project jetty.project by eclipse.
the class TomcatServerQuirksTest method testTomcat7_0_32_WithTransferEncoding.
/**
* Test for when encountering a "Transfer-Encoding: chunked" on a Upgrade Response header.
* <ul>
* <li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=393075">Eclipse Jetty Bug #393075</a></li>
* <li><a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=54067">Apache Tomcat Bug #54067</a></li>
* </ul>
*
* @throws Exception on test failure
*/
@Test
public void testTomcat7_0_32_WithTransferEncoding() throws Exception {
BlockheadServer server = new BlockheadServer();
WebSocketClient client = new WebSocketClient();
try {
final int bufferSize = 512;
server.start();
// Setup Client Factory
client.start();
// Create End User WebSocket Class
LatchedSocket websocket = new LatchedSocket();
// Open connection
URI wsURI = server.getWsUri();
client.connect(websocket, wsURI);
// Accept incoming connection
IBlockheadServerConnection socket = server.accept();
// timeout
socket.setSoTimeout(2000);
// Issue upgrade
// Add the extra problematic header that triggers bug found in jetty-io
socket.addResponseHeader("Transfer-Encoding", "chunked");
socket.upgrade();
// Wait for proper upgrade
Assert.assertTrue("Timed out waiting for Client side WebSocket open event", websocket.openLatch.await(1, TimeUnit.SECONDS));
// Have server write frame.
byte[] payload = new byte[bufferSize / 2];
Arrays.fill(payload, (byte) 'x');
ByteBuffer serverFrame = BufferUtil.allocate(bufferSize);
BufferUtil.flipToFill(serverFrame);
// FIN + TEXT
serverFrame.put((byte) (0x80 | 0x01));
// No MASK and 2 bytes length
serverFrame.put((byte) 0x7E);
// first length byte
serverFrame.put((byte) (payload.length >> 8));
// second length byte
serverFrame.put((byte) (payload.length & 0xFF));
serverFrame.put(payload);
BufferUtil.flipToFlush(serverFrame, 0);
socket.write(serverFrame);
socket.flush();
Assert.assertTrue(websocket.dataLatch.await(1000, TimeUnit.SECONDS));
} finally {
client.stop();
server.stop();
}
}
Aggregations