public async Task <IActionResult> Execute(string id, HttpContext httpContext) { if (!_PublishingId.Validate(id)) { return(new BadRequestResult()); } var e = await _SafeReader.Execute(id); if (e == null) { return(new NotFoundResult()); } var r = new BinaryContentResponse { LastModified = e.Release, PublishingId = e.PublishingId, ContentTypeName = e.ContentTypeName, Content = e.Content, SignedContentTypeName = e.SignedContentTypeName, SignedContent = e.SignedContent }; return(new OkObjectResult(r)); }
public void Execute(HttpContext httpContext, BinaryContentResponse content) { if (httpContext.Request.Headers.TryGetValue("if-none-match", out var etagValue)) { httpContext.Response.ContentLength = 0; httpContext.Response.StatusCode = 400; } //Read if (content == null) { httpContext.Response.StatusCode = 404; httpContext.Response.ContentLength = 0; return; } if (etagValue == content.PublishingId) { httpContext.Response.StatusCode = 304; httpContext.Response.ContentLength = 0; return; } httpContext.Response.Headers.Add("etag", content.PublishingId); httpContext.Response.Headers.Add("last-modified", content.LastModified.ToUniversalTime().ToString("r")); httpContext.Response.Headers.Add("content-type", content.ContentTypeName); httpContext.Response.Body.Write(content.Content); }
public IActionResult Execute(string id) { if (string.IsNullOrWhiteSpace(id)) { return(new BadRequestResult()); } if (Convert.TryFromBase64String(id, new Span <byte>(), out var length) && length == 256) //TODO config { return(new BadRequestResult()); } //TODO anything else to mitigate DDOS? var e = _DbContextProvider.Current.Set <T>() .SingleOrDefault(x => x.PublishingId == id); if (e == null) { return(new NotFoundResult()); } var r = new BinaryContentResponse { LastModified = e.Release, PublishingId = e.PublishingId, ContentTypeName = e.ContentTypeName, Content = e.Content }; return(new OkObjectResult(r)); }
public async Task <IActionResult> Execute(HttpContext httpContext) { var e = await _DynamicManifestReader.Execute(); var r = new BinaryContentResponse { LastModified = e.Release, PublishingId = e.PublishingId, ContentTypeName = e.ContentTypeName, Content = e.Content, SignedContentTypeName = e.SignedContentTypeName, SignedContent = e.SignedContent }; return(new OkObjectResult(r)); }