MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / sendReq

Function sendReq

lib/test/angular/1.7.0/angular.js:12655–12807  ·  view source on GitHub ↗

* Makes the request. * * !!! ACCESSES CLOSURE VARS: * $httpBackend, defaults, $log, $rootScope, defaultCache, $http.pendingRequests

(config, reqData)

Source from the content-addressed store, hash-verified

12653 * $httpBackend, defaults, $log, $rootScope, defaultCache, $http.pendingRequests
12654 */
12655 function sendReq(config, reqData) {
12656 var deferred = $q.defer(),
12657 promise = deferred.promise,
12658 cache,
12659 cachedResp,
12660 reqHeaders = config.headers,
12661 isJsonp = lowercase(config.method) === 'jsonp',
12662 url = config.url;
12663
12664 if (isJsonp) {
12665 // JSONP is a pretty sensitive operation where we're allowing a script to have full access to
12666 // our DOM and JS space. So we require that the URL satisfies SCE.RESOURCE_URL.
12667 url = $sce.getTrustedResourceUrl(url);
12668 } else if (!isString(url)) {
12669 // If it is not a string then the URL must be a $sce trusted object
12670 url = $sce.valueOf(url);
12671 }
12672
12673 url = buildUrl(url, config.paramSerializer(config.params));
12674
12675 if (isJsonp) {
12676 // Check the url and add the JSONP callback placeholder
12677 url = sanitizeJsonpCallbackParam(url, config.jsonpCallbackParam);
12678 }
12679
12680 $http.pendingRequests.push(config);
12681 promise.then(removePendingReq, removePendingReq);
12682
12683 if ((config.cache || defaults.cache) && config.cache !== false &&
12684 (config.method === 'GET' || config.method === 'JSONP')) {
12685 cache = isObject(config.cache) ? config.cache
12686 : isObject(/** @type {?} */ (defaults).cache)
12687 ? /** @type {?} */ (defaults).cache
12688 : defaultCache;
12689 }
12690
12691 if (cache) {
12692 cachedResp = cache.get(url);
12693 if (isDefined(cachedResp)) {
12694 if (isPromiseLike(cachedResp)) {
12695 // cached request has already been sent, but there is no response yet
12696 cachedResp.then(resolvePromiseWithResult, resolvePromiseWithResult);
12697 } else {
12698 // serving from cache
12699 if (isArray(cachedResp)) {
12700 resolvePromise(cachedResp[1], cachedResp[0], shallowCopy(cachedResp[2]), cachedResp[3], cachedResp[4]);
12701 } else {
12702 resolvePromise(cachedResp, 200, {}, 'OK', 'complete');
12703 }
12704 }
12705 } else {
12706 // put the promise for the non-transformed response into cache as a placeholder
12707 cache.put(url, promise);
12708 }
12709 }
12710
12711
12712 // if we won't have the response in cache, set the xsrf headers and

Callers 1

serverRequestFunction · 0.70

Calls 13

lowercaseFunction · 0.70
isStringFunction · 0.70
buildUrlFunction · 0.70
isObjectFunction · 0.70
isDefinedFunction · 0.70
isPromiseLikeFunction · 0.70
isArrayFunction · 0.70
resolvePromiseFunction · 0.70
shallowCopyFunction · 0.70
isUndefinedFunction · 0.70
$httpBackendFunction · 0.70

Tested by

no test coverage detected