OutputStream socketOut = socket.getOutputStream();
InputStream socketIn = socket.getInputStream();
socketOut.write(requestMessage.getBytes(true));
socketOut.write(headers.getUTF8Bytes());
socketOut.flush();
HttpResponse response = HttpResponse.load(socketIn);
String contentType = response.getHeaders().asMap().get("Content-Type");
if(contentType == null) {
contentType = "application/unknown";
}
String xferEncoding = response.getHeaders().asMap().get("Transfer-Encoding");
if(xferEncoding != null) {
if(xferEncoding.equals("chunked")) {
socketIn = new ChunkedInputStream(socketIn);
}