src/Microsoft.PackageManagement.NuGetProvider/NugetLightClient.cs
/// <summary>
/// Send an initial request to download data from the server.
/// From the initial request, we may change the host of subsequent calls (if a redirection happens in this initial request)
/// Also, if the initial request sends us less data than the amount we request, then we do not
/// need to issue more requests
/// </summary>
/// <param name="query"></param>
/// <param name="startPoint"></param>
/// <param name="bufferSize"></param>
/// <param name="request"></param>
/// <returns></returns>
Send an initial request to download data from the server.
From the initial request, we may change the host of subsequent calls (if a redirection happens in this initial request)
Also, if the initial request sends us less data than the amount we request, then we do not
need to issue more requests
Send an initial request to download data from the server . From the initial request we may change the host of subsequent calls ( if a redirection happens in this initial request ) Also if the initial request sends us less data than the amount we request then we do not need to issue more requests
internal static Stream InitialDownloadDataToStream(UriBuilder query, int startPoint, int bufferSize, NuGetRequest request)
        {
            var uri = String.Format(CultureInfo.CurrentCulture, query.Uri.ToString(), startPoint, bufferSize);
            request.Debug(Messages.DownloadingPackage, uri);
            var client = request.Client;
            var response = PathUtility.GetHttpResponse(client, uri, (() => request.IsCanceled),
               ((msg, num) => request.Verbose(Resources.Messages.RetryingDownload, msg, num)), (msg) => request.Verbose(msg), (msg) => request.Debug(msg));
            if (response == null || !response.IsSuccessStatusCode)
            {
                request.Warning(Resources.Messages.CouldNotGetResponseFromQuery, uri);
                return null;
            }
            var stream = GetStreamBasedOnEncoding(response);
            request.Debug(Messages.CompletedDownload, uri);
            if (!String.Equals(response.RequestMessage.RequestUri.Host, query.Host, StringComparison.OrdinalIgnoreCase))
            {
                query.Host = response.RequestMessage.RequestUri.Host;
            }
            return stream;
        }
internal static Stream InitialDownloadDataToStream ( UriBuilder query , int startPoint , int bufferSize , NuGetRequest request ) { var uri = String . Format ( CultureInfo . CurrentCulture , query . Uri . ToString ( ) , startPoint , bufferSize ) ; request . Debug ( Messages . DownloadingPackage , uri ) ; var client = request . Client ; var response = PathUtility . GetHttpResponse ( client , uri , ( ( ) => request . IsCanceled ) , ( ( msg , num ) => request . Verbose ( Resources . Messages . RetryingDownload , msg , num ) ) , ( msg ) => request . Verbose ( msg ) , ( msg ) => request . Debug ( msg ) ) ; if ( response == null || ! response . IsSuccessStatusCode ) { request . Warning ( Resources . Messages . CouldNotGetResponseFromQuery , uri ) ; return null ; } var stream = GetStreamBasedOnEncoding ( response ) ; request . Debug ( Messages . CompletedDownload , uri ) ; if ( ! String . Equals ( response . RequestMessage . RequestUri . Host , query . Host , StringComparison . OrdinalIgnoreCase ) ) { query . Host = response . RequestMessage . RequestUri . Host ; } return stream ; }
Send an initial request to download data from the server.
Send an initial request to download data from the server .
// Check that response was successful or write error // Read response and write out a stream // If the host from the response is different, change the host of the original query
None
query
UriBuilder
None
startPoint
int
None
bufferSize
int
None
request
NuGetRequest
None