use of org.eclipse.jetty.websocket.common.frames.TextFrame in project jetty.project by eclipse.
the class ConfiguratorTest method testCaptureRequestHeadersConfigurator.
@Test
public void testCaptureRequestHeadersConfigurator() throws Exception {
URI uri = baseServerUri.resolve("/capture-request-headers");
try (IBlockheadClient client = new BlockheadClient(uri)) {
client.addHeader("X-Dummy: Bogus\r\n");
client.connect();
client.sendStandardRequest();
client.expectUpgradeResponse();
client.write(new TextFrame().setPayload("X-Dummy"));
EventQueue<WebSocketFrame> frames = client.readFrames(1, 1, TimeUnit.SECONDS);
WebSocketFrame frame = frames.poll();
Assert.assertThat("Frame Response", frame.getPayloadAsUTF8(), is("Request Header [X-Dummy]: \"Bogus\""));
}
}
use of org.eclipse.jetty.websocket.common.frames.TextFrame in project jetty.project by eclipse.
the class ConfiguratorTest method testProtocol_Triple.
/**
* Test of Sec-WebSocket-Protocol, as seen in RFC-6455, 3 protocols
* @throws Exception on test failure
*/
@Test
public void testProtocol_Triple() throws Exception {
URI uri = baseServerUri.resolve("/protocols");
ProtocolsConfigurator.seenProtocols.set(null);
try (IBlockheadClient client = new BlockheadClient(uri)) {
client.addHeader("Sec-WebSocket-Protocol: echo, chat, status\r\n");
client.connect();
client.sendStandardRequest();
client.expectUpgradeResponse();
client.write(new TextFrame().setPayload("getProtocols"));
EventQueue<WebSocketFrame> frames = client.readFrames(1, 1, TimeUnit.SECONDS);
WebSocketFrame frame = frames.poll();
Assert.assertThat("Frame Response", frame.getPayloadAsUTF8(), is("Requested Protocols: [\"echo\",\"chat\",\"status\"]"));
}
}
use of org.eclipse.jetty.websocket.common.frames.TextFrame in project jetty.project by eclipse.
the class ConfiguratorTest method testProtocol_LowercaseHeader.
/**
* Test of Sec-WebSocket-Protocol, using all lowercase header
* @throws Exception on test failure
*/
@Test
public void testProtocol_LowercaseHeader() throws Exception {
URI uri = baseServerUri.resolve("/protocols");
ProtocolsConfigurator.seenProtocols.set(null);
try (IBlockheadClient client = new BlockheadClient(uri)) {
client.addHeader("sec-websocket-protocol: echo, chat, status\r\n");
client.connect();
client.sendStandardRequest();
client.expectUpgradeResponse();
client.write(new TextFrame().setPayload("getProtocols"));
EventQueue<WebSocketFrame> frames = client.readFrames(1, 1, TimeUnit.SECONDS);
WebSocketFrame frame = frames.poll();
Assert.assertThat("Frame Response", frame.getPayloadAsUTF8(), is("Requested Protocols: [\"echo\",\"chat\",\"status\"]"));
}
}
use of org.eclipse.jetty.websocket.common.frames.TextFrame in project jetty.project by eclipse.
the class ServerWriteThread method run.
@Override
public void run() {
final AtomicInteger m = new AtomicInteger();
try {
while (m.get() < messageCount) {
conn.write(new TextFrame().setPayload(message));
m.incrementAndGet();
if (slowness > 0) {
TimeUnit.MILLISECONDS.sleep(slowness);
}
}
} catch (InterruptedException | IOException e) {
LOG.warn(e);
}
}
use of org.eclipse.jetty.websocket.common.frames.TextFrame in project jetty.project by eclipse.
the class TestABCase5 method testCase5_13.
/**
* Send continuation+!fin, then text+fin (framewise)
* @throws Exception on test failure
*/
@Test
public void testCase5_13() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
send.add(new ContinuationFrame().setPayload("sorry").setFin(false));
send.add(new TextFrame().setPayload("hello, world"));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this);
StacklessLogging supress = new StacklessLogging(Parser.class)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.PER_FRAME);
fuzzer.sendAndIgnoreBrokenPipe(send);
fuzzer.expect(expect);
}
}
Aggregations