mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-26 11:10:25 +00:00
chore($http): small $http fixes
This commit is contained in:
parent
67338ce061
commit
b8960c3710
3 changed files with 11 additions and 10 deletions
5
src/angular-mocks.js
vendored
5
src/angular-mocks.js
vendored
|
|
@ -115,7 +115,7 @@ angular.module.ngMock.$Browser = function() {
|
|||
* @description
|
||||
* Flushes all pending requests and executes the defer callbacks.
|
||||
*
|
||||
* @param {number=} number of miliseconds to flush. See {@link #defer.now}
|
||||
* @param {number=} number of milliseconds to flush. See {@link #defer.now}
|
||||
*/
|
||||
self.defer.flush = function(delay) {
|
||||
if (angular.isDefined(delay)) {
|
||||
|
|
@ -629,7 +629,8 @@ angular.module.ngMock.$httpBackendDecorator = function($delegate, $defer) {
|
|||
|
||||
if (!expectation.matchHeaders(headers))
|
||||
throw Error('Expected ' + expectation + ' with different headers\n' +
|
||||
'EXPECTED: ' + prettyPrint(expectation.headers) + '\nGOT: ' + prettyPrint(headers));
|
||||
'EXPECTED: ' + prettyPrint(expectation.headers) + '\nGOT: ' +
|
||||
prettyPrint(headers));
|
||||
|
||||
expectations.shift();
|
||||
|
||||
|
|
|
|||
|
|
@ -118,8 +118,8 @@ function $HttpProvider() {
|
|||
|
||||
var providerResponseInterceptors = this.responseInterceptors = [];
|
||||
|
||||
this.$get = ['$httpBackend', '$browser', '$exceptionHandler', '$cacheFactory', '$rootScope', '$q', '$injector',
|
||||
function($httpBackend, $browser, $exceptionHandler, $cacheFactory, $rootScope, $q, $injector) {
|
||||
this.$get = ['$httpBackend', '$browser', '$cacheFactory', '$rootScope', '$q', '$injector',
|
||||
function($httpBackend, $browser, $cacheFactory, $rootScope, $q, $injector) {
|
||||
|
||||
var defaultCache = $cacheFactory('$http'),
|
||||
responseInterceptors = [];
|
||||
|
|
@ -134,8 +134,10 @@ function $HttpProvider() {
|
|||
* @name angular.module.ng.$http
|
||||
* @requires $httpBacked
|
||||
* @requires $browser
|
||||
* @requires $exceptionHandler //TODO(i): still needed?
|
||||
* @requires $cacheFactory
|
||||
* @requires $rootScope
|
||||
* @requires $q
|
||||
* @requires $injector
|
||||
*
|
||||
* @param {object} config Object describing the request to be made and how it should be processed.
|
||||
* The object has following properties:
|
||||
|
|
@ -369,10 +371,7 @@ function $HttpProvider() {
|
|||
cachedResp = cache.get(config.url);
|
||||
if (cachedResp) {
|
||||
if (cachedResp.then) {
|
||||
// cached request has already been sent, but there is no response yet,
|
||||
// we need to register callback and fire callbacks when the request is back
|
||||
// note, we have to get the values from cache and perform transformations on them,
|
||||
// as the configurations don't have to be same
|
||||
// cached request has already been sent, but there is no response yet
|
||||
cachedResp.then(removePendingReq, removePendingReq);
|
||||
return cachedResp;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, body, locati
|
|||
var status;
|
||||
|
||||
// In IE6 and 7, this might be called synchronously when xhr.send below is called and the
|
||||
// response is in the cache
|
||||
// response is in the cache. the promise api will ensure that to the app code the api is
|
||||
// always async
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == 4) {
|
||||
completeRequest(
|
||||
|
|
|
|||
Loading…
Reference in a new issue