Пример #1
0
        public override async Task <HttpResponseMessage> ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)
        {
            InnerInitialization(controllerContext);
            var authorizer = (MixedModeRequestAuthorizer)controllerContext.Configuration.Properties[typeof(MixedModeRequestAuthorizer)];
            var result     = new HttpResponseMessage();

            if (InnerRequest.Method.Method != "OPTIONS")
            {
                result = await RequestManager.HandleActualRequest(this, controllerContext, async() =>
                {
                    RequestManager.SetThreadLocalState(ReadInnerHeaders, DatabaseName);
                    return(await ExecuteActualRequest(controllerContext, cancellationToken, authorizer));
                }, httpException =>
                {
                    var response = GetMessageWithObject(new { Error = httpException.Message }, HttpStatusCode.ServiceUnavailable);

                    var timeout = httpException.InnerException as TimeoutException;
                    if (timeout != null)
                    {
                        response.Headers.Add("Raven-Database-Load-In-Progress", DatabaseName);
                    }
                    return(response);
                });
            }

            RequestManager.AddAccessControlHeaders(this, result);
            RequestManager.ResetThreadLocalState();

            return(result);
        }
Пример #2
0
        public override HttpResponseMessage GetMessageWithString(string msg, HttpStatusCode code = HttpStatusCode.OK, Etag etag = null)
        {
            var result = base.GetMessageWithString(msg, code, etag);

            RequestManager.AddAccessControlHeaders(this, result);
            HandleReplication(result);
            return(result);
        }
Пример #3
0
        public override async Task <HttpResponseMessage> ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)
        {
            InnerInitialization(controllerContext);
            var authorizer = (MixedModeRequestAuthorizer)controllerContext.Configuration.Properties[typeof(MixedModeRequestAuthorizer)];
            var result     = new HttpResponseMessage();

            if (InnerRequest.Method.Method != "OPTIONS")
            {
                result = await RequestManager.HandleActualRequest(this, async() =>
                {
                    RequestManager.SetThreadLocalState(InnerHeaders, FileSystemName);
                    return(await ExecuteActualRequest(controllerContext, cancellationToken, authorizer));
                }, httpException => GetMessageWithObject(new { Error = httpException.Message }, HttpStatusCode.ServiceUnavailable));
            }

            RequestManager.AddAccessControlHeaders(this, result);
            RequestManager.ResetThreadLocalState();

            return(result);
        }