I want to download in parallel the parts of file. I read that some articles say that. I can use HTTP/1.1 to specify the range i want for each part downloaded at each tcp connection, so I wonder if the following codes can help me to establish a connection while specifying the range. Notice when I excute the codes below nothngi change to the ouput. it seems the following part "Range: bytes=0-500\r\n" doesn't change anything.
Any Help I will I appreciate.
URL url = null;
url = new URL("http://twitter.com/statuses/user_timeline/13507732.atom");
try {
Socket socket = new Socket(url.getHost(), 80);
OutputStream os = socket.getOutputStream();
PrintWriter out = new PrintWriter(os);
String query = url.getQuery();
query = (query == null) ? "" : '?' + query;
String hostname = url.getHost();
// send an HTTP request to the web server
out.write("GET " + url.getPath() + query + " HTTP/1.1\r\n" + // The request
"Host: " + hostname + "\r\n" + // Required in HTTP 1.1
"Range: bytes=0-500\r\n" + // The request
"Connection: close\r\n");
out.println();
out.flush();
// read the response
InputStream inputStream =
socket.getInputStream();
InputStreamReader inputStreamReader =
new InputStreamReader(inputStream);
BufferedReader in =
new BufferedReader(inputStreamReader);
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
// Close everything
out.close();
in.close();
socket.close();
} catch (IOException e) {
System.err.println("Problems talking to " +"twitter user" );
e.printStackTrace();
}
}
}