Skip to content

Commit

Permalink
Merge pull request #890 from dlcs/fix/orchestrator_cache_length
Browse files Browse the repository at this point in the history
Update Orchestrator `PathRewriteTransformer` to set correct `max-age` header values with 404 responses
  • Loading branch information
griffri authored Aug 2, 2024
2 parents 18c5606 + 097db04 commit 4bc6bfb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ public async Task TransformResponseAsync_AddsCacheHeaders_IfImageServer_AndPubli
[InlineData(HttpStatusCode.BadGateway)]
[InlineData(HttpStatusCode.ServiceUnavailable)]
[InlineData(HttpStatusCode.GatewayTimeout)]
[InlineData(HttpStatusCode.NotFound)]
[InlineData(HttpStatusCode.BadRequest)]
public async Task TransformResponseAsync_AddsSmallMaxAge_RegardlessOfDestination_IfError(HttpStatusCode statusCode)
{
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,8 @@ public override ValueTask<bool> TransformResponseAsync(
return new ValueTask<bool>(true);
}

private bool IsDownstreamError(HttpResponseMessage? proxyResponse)
{
var downstreamStatus = proxyResponse?.StatusCode ?? HttpStatusCode.InternalServerError;
return downstreamStatus is HttpStatusCode.InternalServerError
or HttpStatusCode.BadGateway
or HttpStatusCode.ServiceUnavailable
or HttpStatusCode.GatewayTimeout;
}
private bool IsDownstreamError(HttpResponseMessage? proxyResponse)
=> proxyResponse == null || !proxyResponse.IsSuccessStatusCode;

private void EnsureCacheHeaders(HttpContext httpContext, bool isDownstreamError)
{
Expand Down

0 comments on commit 4bc6bfb

Please sign in to comment.