javagwtif-modified-since

Find out if the file has been modified using GWT


I'd like to know whether the image has been modified since some time using GWT. I've found that setting If-Modified-Since http header might work, so I tried to do it like in this post:

RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, "http://www.site.com/pic1.jpg");
rb.setHeader("If-Modified-Since", "Sat, 17 Nov 2012 16:17:00 GMT");
Request r = rb.sendRequest(null, new RequestCallback() {
    public void onResponseReceived(Request request, Response response){
         int i = response.getStatusCode();
         ...
    }

    public void onError(Request request, Throwable exception){
        ...
    }

});

The problem is that I get a status code equals to 0. Could you please tell me what am I doing wrong? Is this a good way to know if the file on server has been modified, or, are there any other ways using GWT? Thanks.


Solution

  • It can be due to SOP as you wrote in comment. You can create php function and then call this function from GWT.