use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class HttpOutputTest method testWriteBufferMed.
@Test
public void testWriteBufferMed() throws Exception {
final Resource big = Resource.newClassPathResource("simple/big.txt");
_handler._writeLengthIfKnown = false;
_handler._content = BufferUtil.toBuffer(big, false);
_handler._byteBuffer = BufferUtil.allocate(4000);
String response = _connector.getResponse("GET / HTTP/1.0\nHost: localhost:80\n\n");
assertThat(response, containsString("HTTP/1.1 200 OK"));
assertThat(response, Matchers.not(containsString("Content-Length")));
assertThat(response, endsWith(toUTF8String(big)));
}
use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class HttpOutputTest method testSendInputStreamBig.
@Test
public void testSendInputStreamBig() throws Exception {
Resource big = Resource.newClassPathResource("simple/big.txt");
_handler._contentInputStream = big.getInputStream();
String response = _connector.getResponse("GET / HTTP/1.0\nHost: localhost:80\n\n");
assertThat(response, containsString("HTTP/1.1 200 OK"));
assertThat(response, Matchers.not(containsString("Content-Length")));
assertThat(response, endsWith(toUTF8String(big)));
}
use of org.eclipse.jetty.util.resource.Resource 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.util.resource.Resource in project jetty.project by eclipse.
the class HttpOutputTest method testWriteByte.
@Test
public void testWriteByte() throws Exception {
final Resource big = Resource.newClassPathResource("simple/big.txt");
_handler._writeLengthIfKnown = false;
_handler._content = BufferUtil.toBuffer(big, false);
_handler._arrayBuffer = new byte[1];
String response = _connector.getResponse("GET / HTTP/1.0\nHost: localhost:80\n\n");
assertThat(response, containsString("HTTP/1.1 200 OK"));
assertThat(response, Matchers.not(containsString("Content-Length")));
assertThat(response, endsWith(toUTF8String(big)));
}
use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class HttpOutputTest method testSendChannelBig.
@Test
public void testSendChannelBig() throws Exception {
Resource big = Resource.newClassPathResource("simple/big.txt");
_handler._contentChannel = big.getReadableByteChannel();
String response = _connector.getResponse("GET / HTTP/1.0\nHost: localhost:80\n\n");
assertThat(response, containsString("HTTP/1.1 200 OK"));
assertThat(response, Matchers.not(containsString("Content-Length")));
assertThat(response, endsWith(toUTF8String(big)));
}
Aggregations