Skip to content

Commit

Permalink
Merge pull request #1056 from scireum/feature/aha/auto-determine-cont…
Browse files Browse the repository at this point in the history
…ent-type

Auto-detects the content-type for Response#outputStream (if possible).
  • Loading branch information
andyHa authored Jun 30, 2022
2 parents d4ad3aa + e57c5d2 commit ab77c08
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/sirius/web/http/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,6 @@ protected void removedChunkedWriteHandler(ChannelFuture writeFuture) {
});
}


/**
* Sends the given file as response.
* <p>
Expand Down Expand Up @@ -1587,6 +1586,10 @@ public ChunkedOutputStream outputStream(HttpResponseStatus status, @Nullable Str
.handle();
}

if (Strings.isEmpty(contentType) && Strings.isFilled(name)) {
contentType = MimeHelper.guessMimeType(name);
}

return new ChunkedOutputStream(this, contentType, status);
}

Expand Down

0 comments on commit ab77c08

Please sign in to comment.