0

I would like to make a HEAD HTTP request to get filesize of the requested url, we can make HTTP GET requests using the below example code from Crossride Docs, my question is how to make a pure HEAD (with no data downloaded) request in croorider:

appAPI.ready(function($) {
    appAPI.request.get({
        url: 'http://example.com/api/get_something.json',
        onSuccess: function(response, additionalInfo) {
            // Display the response
            if (appAPI.utils.isObject(response)) {
                console.log('Response properties:');
                for (p in response) {
                    console.log(response[p] + ': ' + p);
                }
            } else
                console.log('Response: ' + response);

            // Stringify and display the response headers
            var headersAsString = '';
            for (var x in additionalInfo.headers) {
                headersAsString += '\n' + x + ': ' + additionalInfo.headers[x];
            }
            console.log('Response Headers:' + headersAsString);
        },
        onFailure: function(httpCode) {
            console.log('Failed to retrieve content. (HTTP Code:' + httpCode + ')');
        },
        additionalRequestHeaders: {
            myHeader: 'value'
        },
        responseDataType: 'application/json'
    });
});
Stacked
  • 841
  • 2
  • 12
  • 23
  • Well i can offer a workarounds: If you control the remote url, do that if you add some QS param, EG: ?head=true the response will be JSON with information about the file. or you don't control, you can use a proxy server side file that will fetch the info for you – Bnaya Jan 24 '15 at 23:54
  • No, I don't. They are third-party servers. – Stacked Jan 25 '15 at 03:43
  • Currently, the only supported methods are GET and POST. There are plans to extend the list and I've requested that HEAD be added as well. However, it will be a while before it's developed, QA'd and released. I am not aware of any workarounds, but you can try a regular jQuery AJAX, preferably from the background scope to avoid CORS issues. [**Disclosure**: I am a Crossrider employee] – Shlomo Jan 25 '15 at 09:11

0 Answers0