MockChannel channel = new MockChannel(null);
MockMonitor monitor = new MockMonitor();
MockRequest request = new MockRequest();
MockResponse response = new MockResponse();
Conversation support = new Conversation(request, response);
Transfer transfer = new Transfer(response, support, channel, monitor);
// Start a HTTP/1.1 conversation
request.setMajor(1);
request.setMinor(1);
transfer.start(1024);
assertEquals(response.getValue("Connection"), "keep-alive");
assertEquals(response.getValue("Content-Length"), "1024");
assertEquals(response.getValue("Transfer-Encoding"), null);
assertEquals(response.getContentLength(), 1024);
assertTrue(response.isCommitted());
channel = new MockChannel(null);
monitor = new MockMonitor();
request = new MockRequest();
response = new MockResponse();
support = new Conversation(request, response);
transfer = new Transfer(response, support, channel, monitor);
// Start a HTTP/1.0 conversation
request.setMajor(1);
request.setMinor(0);
transfer.start(1024);
assertEquals(response.getValue("Connection"), "close");
assertEquals(response.getValue("Content-Length"), "1024");
assertEquals(response.getValue("Transfer-Encoding"), null);
assertEquals(response.getContentLength(), 1024);
assertTrue(response.isCommitted());
channel = new MockChannel(null);
monitor = new MockMonitor();
request = new MockRequest();
response = new MockResponse();
support = new Conversation(request, response);
transfer = new Transfer(response, support, channel, monitor);
// Start a HTTP/1.0 conversation
request.setMajor(1);
request.setMinor(1);
response.setValue("Content-Length", "2048");
response.setValue("Connection", "close");
response.setValue("Transfer-Encoding", "chunked");
transfer.start(1024);
assertEquals(response.getValue("Connection"), "close");
assertEquals(response.getValue("Content-Length"), "1024"); // should be 1024
assertEquals(response.getValue("Transfer-Encoding"), null);
assertEquals(response.getContentLength(), 1024);