use of org.eclipse.jetty.util.log.AbstractLogger in project jetty.project by eclipse.
the class HttpServerTestBase method testFullURI.
/*
* Feed a full header method
*/
@Test
public void testFullURI() throws Exception {
configureServer(new HelloWorldHandler());
try (Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort());
StacklessLogging stackless = new StacklessLogging(HttpConnection.class)) {
((AbstractLogger) Log.getLogger(HttpConnection.class)).info("expect URI is too large, then ISE extra data ...");
OutputStream os = client.getOutputStream();
byte[] buffer = new byte[64 * 1024];
buffer[0] = 'G';
buffer[1] = 'E';
buffer[2] = 'T';
buffer[3] = ' ';
buffer[4] = '/';
Arrays.fill(buffer, 5, buffer.length - 1, (byte) 'A');
os.write(buffer);
os.flush();
// Read the response.
String response = readResponse(client);
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 414 "));
}
}
use of org.eclipse.jetty.util.log.AbstractLogger in project jetty.project by eclipse.
the class HttpServerTestBase method testFullMethod.
/*
* Feed a full header method
*/
@Test
public void testFullMethod() throws Exception {
configureServer(new HelloWorldHandler());
try (Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort());
StacklessLogging stackless = new StacklessLogging(HttpConnection.class)) {
client.setSoTimeout(10000);
((AbstractLogger) Log.getLogger(HttpConnection.class)).info("expect request is too large, then ISE extra data ...");
OutputStream os = client.getOutputStream();
byte[] buffer = new byte[64 * 1024];
Arrays.fill(buffer, (byte) 'A');
os.write(buffer);
os.flush();
// Read the response.
String response = readResponse(client);
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 431 "));
}
}
use of org.eclipse.jetty.util.log.AbstractLogger in project jetty.project by eclipse.
the class HttpServerTestBase method testCommittedError.
@Test
public void testCommittedError() throws Exception {
CommittedErrorHandler handler = new CommittedErrorHandler();
configureServer(handler);
try (Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort());
StacklessLogging stackless = new StacklessLogging(HttpChannel.class)) {
((AbstractLogger) Log.getLogger(HttpChannel.class)).info("Expecting exception after commit then could not send 500....");
OutputStream os = client.getOutputStream();
InputStream is = client.getInputStream();
// Send a request
os.write(("GET / HTTP/1.1\r\n" + "Host: " + _serverURI.getHost() + ":" + _serverURI.getPort() + "\r\n" + "\r\n").getBytes());
os.flush();
client.setSoTimeout(2000);
String in = IO.toString(is);
// Closed by error!
assertEquals(-1, is.read());
assertThat(in, containsString("HTTP/1.1 200 OK"));
assertTrue(in.indexOf("Transfer-Encoding: chunked") > 0);
assertTrue(in.indexOf("Now is the time for all good men to come to the aid of the party") > 0);
assertThat(in, Matchers.not(Matchers.containsString("\r\n0\r\n")));
client.close();
Thread.sleep(200);
assertTrue(!handler._endp.isOpen());
}
}
Aggregations