Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

How to make an HEAD Http request in Crossrider extension?


  • Please log in to reply
2 replies to this topic

#1 dartNekuda

dartNekuda

  • Members
  • 1 posts
  • OFFLINE
  •  
  • Local time:10:48 PM

Posted 18 February 2015 - 03:58 AM

Hey,

I would like to make a HEAD HTTP request to get filesize of the requested url, I 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'
});
});



BC AdBot (Login to Remove)

 


#2 drawin

drawin

  • Members
  • 1 posts
  • OFFLINE
  •  
  • Local time:10:48 PM

Posted 23 February 2015 - 07:12 AM

Hey,

The Crossrider API only supports GET and POST. I've read somewhere that they intend to add verbs in the future so it should be released at some stage. For now try using standard jQuery AJAX.

you can ask them on stackoverflow.com/questions/tagged/crossrider

 

 

 

Cheers

J.



#3 maxwellkom

maxwellkom

  • Members
  • 1 posts
  • OFFLINE
  •  
  • Local time:04:48 AM

Posted 15 April 2015 - 07:35 AM

The Content-Length HTTP Headerwill give an approximate on the file size, which is part of the HTTP HEAD request. This will obtain you the necessary information without transferring any of the content in the response.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users