public void End(IResponseContext context) { // TODO MINOR - for some reason a single request invokes events on 3 workers when requesting /. This is causing some skewed metrics. // The first event appears to be correct - as completion actually sends headers to the client. // The other two requests are either for ~/default.aspx or ~/ - which makes me wonder if this is caused by the rewrite module. // In any case, these requests are canceled (requested) when the first request completes - ignoring for now. var requestTime = _timeline.GetTimeSinceTick(_requestStartTick); _storage.AddRequest(requestTime, _handlerTime, context.ResponseSizeBytes); context.AddHeader("X-Spectaris-Request-Count", _storage.TotalTimeMilliseconds.Count.ToString()); }
public void ProcessResult(IRequestContext request, IResponseContext response) { var fullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FilePath); if (!File.Exists(fullPath)) { throw new FileNotFoundException(String.Format("The file at {0} could not be found", fullPath)); } response.AddHeader("Content-Disposition", String.Format("attachment; filename={0}", Path.GetFileName(fullPath))); response.ContentType = getContentType(fullPath); response.WriteFile(fullPath); }
private static ExecuteResult Execute <TInput>( IProcessingEngine engine, IServerCommandDescription <TInput>[] commands, IRequestContext request, IResponseContext response) { var result = engine.Execute <TInput, object>(commands, request.Principal); var first = result.ExecutedCommandResults != null?result.ExecutedCommandResults.FirstOrDefault() : null; response.StatusCode = first != null && first.Result != null ? first.Result.Status : result.Status; if (result.Status == HttpStatusCode.ServiceUnavailable) { HttpRuntime.UnloadAppDomain(); } var noResult = first == null || first.Result == null || first.Result.Data == null; if ((int)result.Status >= 300 && noResult) { return new ExecuteResult { Error = response.ReturnError(result.Message, result.Status) } } ; if (first == null) { return new ExecuteResult { Error = response.ReturnError("Missing result", HttpStatusCode.InternalServerError) } } ; if ((int)first.Result.Status >= 300 && noResult) { return new ExecuteResult { Error = response.ReturnError(first.Result.Message, first.Result.Status) } } ; foreach (var ar in result.ExecutedCommandResults.Skip(1)) { response.AddHeader(ar.RequestID, ar.Result.Data.ToString()); } return(new ExecuteResult { Result = first.Result.Data }); }
public void UpdateContext(IResponseContext context) { context.AddHeader(CacheControl.LongCachingPolicy); context.AddEntityBodyTransformationStrategyFactoryMethod(stream => new CopyEntityBody(stream)); innerRepresentation.UpdateContext(context); }
public void UpdateContext(IResponseContext context) { context.AddHeader(ContentType.Atom).AddHeader(chunking).AddHeader(eTag).AddHeader(lastModified); context.AddEntityBodyStreamAccessMethod(() => fileInfo.OpenRead()); }