private void DownloadAsync(IWWWRequest wwwRequest, string originalUrl, string redirectedUrl, Action <WWWResponse> callback)
        {
            WWWRequestWrapper requestWrapper;

            // It is possible for 'SendGetRequest' or 'SendPostRequest' to have completed immediately.
            // If this is the case, then we don't mark the request as pending.
            var responseReceived = false;

            Action <WWWResponse> responseHandler = (response) =>
            {
                responseReceived = true;
                DownloadAsyncResponse(response, wwwRequest, originalUrl, callback);
            };

            var headers = GetCacheHeaders(originalUrl);

            if (headers == null)
            {
                requestWrapper = wwwRequest.SendGetRequest(coroutineHost, redirectedUrl, responseHandler);
            }
            else
            {
                requestWrapper = wwwRequest.SendPostRequest(coroutineHost, redirectedUrl, null, headers, responseHandler);
            }

            if (!responseReceived)
            {
                pendingDownloadRequests.Add(requestWrapper);
            }
        }
 internal AssetBundleDownloader(string cachePath, IMachineCache <byte[], AssetBundle> assetCache, IMachineCache <CacheEntry, CacheEntry> metaDataCache, IWWWRequest wwwRequest, MonoBehaviour coroutineHost)
 {
     this.cachePath     = cachePath;
     this.assetCache    = assetCache;
     this.metaDataCache = metaDataCache;
     this.wwwRequest    = wwwRequest;
     this.coroutineHost = coroutineHost;
 }
        private CloudAssemblyArtifactResolver(MonoBehaviour coroutineHost, IWWWRequest wwwRequest, string infraServiceUrl, string projectName, string assemblyName, Action <Dictionary <string, string> > onAssetsResolved, Action <Exception> onFailed)
        {
            this.coroutineHost    = coroutineHost;
            this.wwwRequest       = wwwRequest;
            this.infraServiceUrl  = infraServiceUrl;
            this.projectName      = projectName;
            this.assemblyName     = assemblyName;
            this.onAssetsResolved = onAssetsResolved;
            this.onFailed         = onFailed;

            taskRunner = new TaskRunnerWithExponentialBackoff <WWWResponse>();

            state = State.WaitingToStart;
        }
        private void DownloadAsyncResponse(WWWResponse response, IWWWRequest wwwRequest, string originalUrl, Action <WWWResponse> callback)
        {
            pendingDownloadRequests.Remove(response.Request);

            var redirectUrl = GetRedirectUrl(response);

            if (redirectUrl != null)
            {
                DownloadAsync(wwwRequest, originalUrl, redirectUrl, callback);
            }
            else
            {
                callback(response);
            }
        }
        public static CloudAssemblyArtifactResolver ResolveAssetUrls(MonoBehaviour coroutineHost, IWWWRequest wwwRequest, string infraServiceUrl, string projectName, string assemblyName, Action <Dictionary <string, string> > onAssetsResolved, Action <Exception> onFailed)
        {
            var resolver = new CloudAssemblyArtifactResolver(coroutineHost, wwwRequest, infraServiceUrl, projectName, assemblyName, onAssetsResolved, onFailed);

            resolver.Start();

            return(resolver);
        }