use of org.eclipse.jetty.server.LocalConnector.LocalEndPoint in project jetty.project by eclipse.
the class HttpOutputTest method testSendInputStreamBigChunked.
@Test
public void testSendInputStreamBigChunked() throws Exception {
Resource big = Resource.newClassPathResource("simple/big.txt");
_handler._contentInputStream = new FilterInputStream(big.getInputStream()) {
@Override
public int read(byte[] b, int off, int len) throws IOException {
int filled = super.read(b, off, len > 2000 ? 2000 : len);
return filled;
}
};
LocalEndPoint endp = _connector.executeRequest("GET / HTTP/1.1\nHost: localhost:80\n\n" + "GET / HTTP/1.1\nHost: localhost:80\nConnection: close\n\n");
String response = endp.getResponse();
assertThat(response, containsString("HTTP/1.1 200 OK"));
assertThat(response, containsString("Transfer-Encoding: chunked"));
assertThat(response, containsString("1\tThis is a big file"));
assertThat(response, containsString("400\tThis is a big file"));
assertThat(response, containsString("\r\n0\r\n"));
response = endp.getResponse();
assertThat(response, containsString("HTTP/1.1 200 OK"));
assertThat(response, containsString("Connection: close"));
}
use of org.eclipse.jetty.server.LocalConnector.LocalEndPoint in project jetty.project by eclipse.
the class HttpConnectionTest method testUnconsumedErrorRead.
@Test
public void testUnconsumedErrorRead() throws Exception {
int offset = 0;
String requests = "GET /R1?read=1&error=499 HTTP/1.1\r\n" + "Host: localhost\r\n" + "Transfer-Encoding: chunked\r\n" + "Content-Type: text/plain; charset=utf-8\r\n" + "\r\n" + "5;\r\n" + "12345\r\n" + "5;\r\n" + "67890\r\n" + "0;\r\n" + "\r\n" + "GET /R2 HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: text/plain; charset=utf-8\r\n" + "Content-Length: 10\r\n" + "Connection: close\r\n" + "\r\n" + "abcdefghij\r\n";
LocalEndPoint endp = connector.executeRequest(requests);
String response = endp.getResponse() + endp.getResponse();
offset = checkContains(response, offset, "HTTP/1.1 499");
offset = checkContains(response, offset, "HTTP/1.1 200");
offset = checkContains(response, offset, "/R2");
offset = checkContains(response, offset, "encoding=UTF-8");
checkContains(response, offset, "abcdefghij");
}
use of org.eclipse.jetty.server.LocalConnector.LocalEndPoint in project jetty.project by eclipse.
the class HttpConnectionTest method testUnconsumedErrorStream.
@Test
public void testUnconsumedErrorStream() throws Exception {
int offset = 0;
String requests = "GET /R1?error=599 HTTP/1.1\r\n" + "Host: localhost\r\n" + "Transfer-Encoding: chunked\r\n" + "Content-Type: application/data; charset=utf-8\r\n" + "\r\n" + "5;\r\n" + "12345\r\n" + "5;\r\n" + "67890\r\n" + "0;\r\n" + "\r\n" + "GET /R2 HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: text/plain; charset=utf-8\r\n" + "Content-Length: 10\r\n" + "Connection: close\r\n" + "\r\n" + "abcdefghij\r\n";
LocalEndPoint endp = connector.executeRequest(requests);
String response = endp.getResponse() + endp.getResponse();
offset = checkContains(response, offset, "HTTP/1.1 599");
offset = checkContains(response, offset, "HTTP/1.1 200");
offset = checkContains(response, offset, "/R2");
offset = checkContains(response, offset, "encoding=UTF-8");
checkContains(response, offset, "abcdefghij");
}
use of org.eclipse.jetty.server.LocalConnector.LocalEndPoint in project jetty.project by eclipse.
the class HttpConnectionTest method test_0_9.
@Test
public void test_0_9() throws Exception {
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616);
LocalEndPoint endp = connector.executeRequest("GET /R1\n");
endp.waitUntilClosed();
String response = BufferUtil.toString(endp.takeOutput());
int offset = 0;
checkNotContained(response, offset, "HTTP/1.1");
checkNotContained(response, offset, "200");
checkContains(response, offset, "pathInfo=/R1");
}
use of org.eclipse.jetty.server.LocalConnector.LocalEndPoint in project jetty.project by eclipse.
the class HttpConnectionTest method testUnconsumed.
@Test
public void testUnconsumed() throws Exception {
int offset = 0;
String requests = "GET /R1?read=4 HTTP/1.1\r\n" + "Host: localhost\r\n" + "Transfer-Encoding: chunked\r\n" + "Content-Type: text/plain; charset=utf-8\r\n" + "\r\n" + "5;\r\n" + "12345\r\n" + "5;\r\n" + "67890\r\n" + "0;\r\n" + "\r\n" + "GET /R2 HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: text/plain; charset=utf-8\r\n" + "Content-Length: 10\r\n" + "Connection: close\r\n" + "\r\n" + "abcdefghij\r\n";
LocalEndPoint endp = connector.executeRequest(requests);
String response = endp.getResponse() + endp.getResponse();
offset = checkContains(response, offset, "HTTP/1.1 200");
offset = checkContains(response, offset, "pathInfo=/R1");
offset = checkContains(response, offset, "1234");
checkNotContained(response, offset, "56789");
offset = checkContains(response, offset, "HTTP/1.1 200");
offset = checkContains(response, offset, "pathInfo=/R2");
offset = checkContains(response, offset, "encoding=UTF-8");
checkContains(response, offset, "abcdefghij");
}
Aggregations