@Test
public void testQuotedEncoding() throws Exception {
RequestHandler rh = new RequestHandler();
IServer server = new HttpServer(rh);
server.start();
IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
con.write("POST / HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"User-Agent: me\r\n" +
"Content-Length: 5\r\n" +
"Content-Type: text/plain;charset=\"iso-8859-1\"\r\n" +
"\r\n" +
"12345");
String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
int contentLength = QAUtil.readContentLength(header);
String body = con.readStringByLength(contentLength);
Assert.assertTrue(header.indexOf("200") != -1);
Assert.assertEquals("OK", body);
Set<String> headerNames = rh.getRequest().getHeaderNameSet();
Assert.assertTrue(headerNames.remove("User-Agent"));
Assert.assertTrue(headerNames.remove("Host"));
Assert.assertEquals("iso-8859-1", rh.getRequest().getCharacterEncoding());
Assert.assertEquals("12345", rh.getRequest().getBody().toString());
con.close();
server.close();
}