Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

determine if server supports resume get request

How does one determine if a server supports resuming a file transfer or get request?

My thoughts were to set the header to start the get request at byte "2" instead of 0, and immediately closing the http request if that gave the proper result

but I was wondering if there was something about the server response for a different kind of probe that would reveal this information to me

like image 939
CQM Avatar asked Aug 06 '13 15:08

CQM


People also ask

How do I know if my server supports range requests?

Furthermore, you can check Accept-Ranges on the response header to judge whether it can support range, but please notice if the value is none on Accept-Ranges field, it means it can't support range, and if the response header doesn't have Accept-Ranges field you also can't finger out it can't support range from it.

What is range header?

The Range HTTP request header indicates the part of a document that the server should return. Several parts can be requested with one Range header at once, and the server may send back these ranges in a multipart document. If the server sends back ranges, it uses the 206 Partial Content for the response.


1 Answers

To probe the download resume feature of a server, you may send a HEAD request to the server supplying a Range header with arbitrary values. If the response code is 206, then resume is supported.

Example with curl:

$ curl -i -X HEAD --header "Range: bytes=50-100" http://mirrors.melbourne.co.uk/ubuntu-releases//raring/ubuntu-13.04-desktop-amd64.iso

Update:

Here's an example in Java:

import org.apache.http.client.ResponseHandler; import org.apache.http.client.HttpClient; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpHead; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicHeader;  public class ResumeChecker {      public final static void main(String[] args) throws Exception {          HttpClient httpclient = new DefaultHttpClient();         HttpHead httpRequest = new HttpHead("http://www.google.com");         httpRequest.addHeader(new BasicHeader("Range", "bytes=10-20"));          System.out.println("Executing request " + httpRequest.getURI());          HttpResponse response = httpclient.execute(httpRequest);          // Check here that response.getStatusLine() contains 206 code     } } 

However, I haven't tested it mysqlf.

like image 157
aadel Avatar answered Sep 29 '22 14:09

aadel