port = 80;
}
byte GET[] = "GET".getBytes();
byte HTTP11[] = "HTTP/1.1".getBytes();
InetAddress addr = InetAddress.getByName(hostname);
HttpRequestMessage requestMessage = new HttpRequestMessage(
GET,url.getFile().getBytes(),HTTP11);
ANVLRecord headers = new ANVLRecord();
headers.addLabelValue("Host", hostname);
if(offset != 0) {
headers.addLabelValue(RANGE_HTTP_HEADER,
HEADER_BYTES_PREFIX + String.valueOf(offset) +
HEADER_BYTES_SUFFIX);
}
InetSocketAddress sockAddr = new InetSocketAddress(addr,port);
Socket socket = new Socket();
socket.setSoTimeout(socketTimeoutMs);
socket.setReceiveBufferSize(BUF_SIZE);
socket.connect(sockAddr, connectTimeoutMs);
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) {