如何在Crossrider扩展中发出HEAD Http请求?

时间:2015-01-24 09:16:11

标签: javascript cross-browser browser-extension crossrider

我想发送一个HEAD HTTP请求来获取所请求网址的文件大小,我们可以使用以下来自Crossride Docs的示例代码发出HTTP GET个请求,我的问题是如何制作一个纯文件在croorider中HEAD(没有下载数据)请求:

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'
    });
});

0 个答案:

没有答案