tweaks and history

This commit is contained in:
David Glasser
2015-06-16 13:45:09 -07:00
parent 60a0c2401d
commit f75eb8910e
3 changed files with 15 additions and 8 deletions

View File

@@ -1,5 +1,14 @@
## v.NEXT
### Utilities
* New `beforeSend` option to `HTTP.call` on the client allows you to directly
access the `XMLHttpRequest` object and abort the call. #4419 #3243 #3266
## in progress: v.1.1.1
### Blaze
* Preparatory work for the yet-unreleased `react-template-helper`

View File

@@ -13,7 +13,7 @@
* @param {Number} options.timeout Maximum time in milliseconds to wait for the request before failing. There is no timeout by default.
* @param {Boolean} options.followRedirects If `true`, transparently follow HTTP redirects. Cannot be set to `false` on the client. Default `true`.
* @param {Object} options.npmRequestOptions On the server, `HTTP.call` is implemented by using the [npm `request` module](https://www.npmjs.com/package/request). Any options in this object will be passed directly to the `request` invocation.
* @param {Function} options.beforeSend On the Client, this will be called before the request is sent to allow for more granular ajax manipulation, `xhr` object is passed as the first argument, returning false within this callback will cancel the request.
* @param {Function} options.beforeSend On the client, this will be called before the request is sent to allow for more direct manipulation of the underlying XMLHttpRequest object, which will be passed as the first argument. If the callback returns `false`, the request will be not be send.
* @param {Function} [asyncCallback] Optional callback. If passed, the method runs asynchronously, instead of synchronously, and calls asyncCallback. On the client, this callback is required.
*/
HTTP.call = function(method, url, options, callback) {

View File

@@ -454,20 +454,18 @@ testAsyncMulti("httpcall - npmRequestOptions", [
}
]);
testAsyncMulti("httpcall - beforeSend", [
Meteor.isClient && testAsyncMulti("httpcall - beforeSend", [
function (test, expect) {
var fired = false;
var bSend = function(xhr){
test.isFalse(fired);
fired = true;
test.isTrue(temp1 instanceof XMLHttpRequest);
test.isTrue(xhr instanceof XMLHttpRequest);
};
if (Meteor.isClient) {
HTTP.get(url_prefix() + "/", {beforeSend: bSend}, function () {
test.isTrue(fired)
});
}
HTTP.get(url_prefix() + "/", {beforeSend: bSend}, expect(function () {
test.isTrue(fired);
}));
}
]);