InvokeLogRequest() private method

Invoke the LogRequest event
private InvokeLogRequest ( IHoldProfilingInformation sender, Func generateRequestResult ) : void
sender IHoldProfilingInformation
generateRequestResult Func
return void
コード例 #1
0
ファイル: HttpJsonRequest.cs プロジェクト: lahma/ravendb
        /// <summary>
        /// Begins the read response string.
        /// </summary>
        public async Task <RavenJToken> ReadResponseJsonAsync()
        {
            if (SkipServerCheck)
            {
                var cachedResult = factory.GetCachedResponse(this);
                factory.InvokeLogRequest(owner, () => new RequestResultArgs
                {
                    DurationMilliseconds = CalculateDuration(),
                    Method     = Method,
                    HttpResult = (int)ResponseStatusCode,
                    Status     = RequestStatus.AggressivelyCached,
                    Result     = cachedResult.ToString(),
                    Url        = Url,
                    PostedData = postedData
                });
                return(cachedResult);
            }

            if (writeCalled)
            {
                return(await ReadJsonInternalAsync().ConfigureAwait(false));
            }

            var result = await SendRequestInternal(() => new HttpRequestMessage(new HttpMethod(Method), Url)).ConfigureAwait(false);

            if (result != null)
            {
                return(result);
            }
            return(await ReadJsonInternalAsync().ConfigureAwait(false));
        }
コード例 #2
0
 public bool CanFullyCache(HttpJsonRequestFactory jsonRequestFactory, HttpJsonRequest httpJsonRequest, string postedData)
 {
     if (allRequestsCanBeServedFromAggressiveCache)             // can be fully served from aggressive cache
     {
         jsonRequestFactory.InvokeLogRequest(holdProfilingInformation, new RequestResultArgs
         {
             DurationMilliseconds = httpJsonRequest.CalculateDuration(),
             Method     = httpJsonRequest.webRequest.Method,
             HttpResult = 0,
             Status     = RequestStatus.AggresivelyCached,
             Result     = "",
             Url        = httpJsonRequest.webRequest.RequestUri.PathAndQuery,
             PostedData = postedData
         });
         return(true);
     }
     return(false);
 }
コード例 #3
0
ファイル: MultiGetOperation.cs プロジェクト: quenth/ravendb
		public bool CanFullyCache(HttpJsonRequestFactory jsonRequestFactory, HttpJsonRequest httpJsonRequest, string postedData)
		{
			if (allRequestsCanBeServedFromAggressiveCache) // can be fully served from aggresive cache
			{
				jsonRequestFactory.InvokeLogRequest(holdProfilingInformation, new RequestResultArgs
				{
					DurationMilliseconds = httpJsonRequest.CalculateDuration(),
					Method = httpJsonRequest.webRequest.Method,
					HttpResult = 0,
					Status = RequestStatus.AggresivelyCached,
					Result = "",
					Url = httpJsonRequest.webRequest.RequestUri.PathAndQuery,
					PostedData = postedData
				});
				return true;
			}
			return false;
		}
コード例 #4
0
ファイル: HttpJsonRequest.cs プロジェクト: webmonger/ravendb
        /// <summary>
        /// Begins the read response string.
        /// </summary>
        public Task <RavenJToken> ReadResponseJsonAsync()
        {
            if (SkipServerCheck)
            {
                var tcs            = new TaskCompletionSource <RavenJToken>();
                var cachedResponse = factory.GetCachedResponse(this);
                factory.InvokeLogRequest(owner, () => new RequestResultArgs
                {
                    DurationMilliseconds = CalculateDuration(),
                    Method     = webRequest.Method,
                    HttpResult = (int)ResponseStatusCode,
                    Status     = RequestStatus.AggressivelyCached,
                    Result     = cachedResponse.ToString(),
                    Url        = webRequest.RequestUri.PathAndQuery,
                    PostedData = postedData
                });
                tcs.SetResult(cachedResponse);
                return(tcs.Task);
            }

            return(InternalReadResponseStringAsync(retries: 0));
        }
コード例 #5
0
        /// <summary>
        /// Begins the read response string.
        /// </summary>
        public async Task <RavenJToken> ReadResponseJsonAsync()
        {
            if (SkipServerCheck)
            {
                var result = factory.GetCachedResponse(this);
                factory.InvokeLogRequest(owner, () => new RequestResultArgs
                {
                    DurationMilliseconds = CalculateDuration(),
                    Method     = webRequest.Method,
                    HttpResult = (int)ResponseStatusCode,
                    Status     = RequestStatus.AggressivelyCached,
                    Result     = result.ToString(),
                    Url        = webRequest.RequestUri.PathAndQuery,
                    PostedData = postedData
                });
                return(result);
            }

            int retries = 0;

            while (true)
            {
                WebException    webException;
                HttpWebResponse httpWebResponse;

                try
                {
                    if (writeCalled == false)
                    {
                        webRequest.ContentLength = 0;
                    }
                    return(await ReadJsonInternalAsync(webRequest.GetResponseAsync()));
                }
                catch (WebException e)
                {
                    if (++retries >= 3 || disabledAuthRetries)
                    {
                        throw;
                    }

                    httpWebResponse = e.Response as HttpWebResponse;
                    if (httpWebResponse == null ||
                        (httpWebResponse.StatusCode != HttpStatusCode.Unauthorized &&
                         httpWebResponse.StatusCode != HttpStatusCode.Forbidden &&
                         httpWebResponse.StatusCode != HttpStatusCode.PreconditionFailed))
                    {
                        throw;
                    }

                    webException = e;
                }

                if (httpWebResponse.StatusCode == HttpStatusCode.Forbidden)
                {
                    await HandleForbiddenResponseAsync(httpWebResponse);

                    await new CompletedTask(webException).Task;                     // Throws, preserving original stack
                }

                if (await HandleUnauthorizedResponseAsync(httpWebResponse) == false)
                {
                    await new CompletedTask(webException).Task;                     // Throws, preserving original stack
                }
            }
        }