/// <summary> /// Processes the HTTP request for static files. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public RequestHandlingResult ProcessRequest(HttpContext context) { var relativeFilePath = _fileHandler.GetRelativeFilePath(context.Request); var lastModificationTime = _fileHandler.GetFileLastModificationTime(relativeFilePath); var response = _responseFactory.Create(context.Response); return(_fileHandler.IsFileCanBeUsedFromCache(context.Request.Headers["Cache-Control"], _fileHandler.GetIfModifiedSinceTime(context.Request.Headers), lastModificationTime) ? RequestHandlingResult.HandledResult(response.SendNotModified(lastModificationTime, relativeFilePath)) : RequestHandlingResult.HandledResult(response.SendNew(_fileHandler.GetFileData(relativeFilePath), lastModificationTime, relativeFilePath))); }
/// <summary> /// Processes the HTTP request for static files. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public Task ProcessRequest(IOwinContext context) { var relativeFilePath = _fileHandler.GetRelativeFilePath(context.Request); var lastModificationTime = _fileHandler.GetFileLastModificationTime(relativeFilePath); var response = _responseFactory.Create(context.Response); return(_fileHandler.IsFileCanBeUsedFromCache(context.Request.CacheControl, _fileHandler.GetIfModifiedSinceTime(context.Request.Headers), lastModificationTime) ? response.SendNotModified(lastModificationTime, relativeFilePath) : response.SendNew(_fileHandler.GetFileData(relativeFilePath), lastModificationTime, relativeFilePath)); }
/// <summary> /// Processes the HTTP request for static files. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public async Task <RequestHandlingStatus> ProcessRequest(HttpContext context) { var relativeFilePath = _fileHandler.GetRelativeFilePath(context.Request); var lastModificationTime = _fileHandler.GetFileLastModificationTime(relativeFilePath); var response = _responseFactory.Create(context.Response); if (_fileHandler.IsFileCanBeUsedFromCache(context.Request.Headers["Cache-Control"], _fileHandler.GetIfModifiedSinceTime(context.Request.Headers), lastModificationTime)) { await response.SendNotModified(lastModificationTime, relativeFilePath); } else { await response.SendNew(await _fileHandler.GetFileData(relativeFilePath), lastModificationTime, relativeFilePath); } return(RequestHandlingStatus.RequestWasHandled); }