Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.avaje.jex.staticcontent;

import static io.avaje.jex.core.Constants.CONTENT_TYPE;

import java.net.URL;
import java.nio.file.Paths;
import java.util.Map;
Expand Down Expand Up @@ -85,7 +87,7 @@ public void handle(Context ctx) {

private void sendURL(Context ctx, String urlPath, URL path) {
try (var fis = path.openStream()) {
ctx.header("Content-Type", lookupMime(urlPath));
ctx.header(CONTENT_TYPE, lookupMime(urlPath));
ctx.headers(headers);
if (precompress) {
addCachedEntry(ctx, urlPath, fis);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.avaje.jex.staticcontent;

import static io.avaje.jex.core.Constants.CONTENT_TYPE;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -100,7 +102,7 @@ private void sendFile(Context ctx, HttpExchange jdkExchange, String urlPath, Fil
throws IOException {
try (var fis = new FileInputStream(canonicalFile)) {
String mimeType = lookupMime(urlPath);
ctx.header("Content-Type", mimeType);
ctx.header(CONTENT_TYPE, mimeType);
ctx.headers(headers);
if (precompress) {
addCachedEntry(ctx, urlPath, fis);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public CompressedOutputStream(
private void decideCompression(int length) throws IOException {
if (!compressionDecided) {
boolean compressionAllowed =
compressedStream == null && compression.allowsForCompression(ctx.contentType());
compressedStream == null
&& compression.allowsForCompression(ctx.responseHeader(Constants.CONTENT_TYPE));

if (compressionAllowed && length >= minSizeForCompression) {
Optional<Compressor> compressor;
Expand Down
1 change: 1 addition & 0 deletions avaje-jex/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
exports io.avaje.jex.compression;
exports io.avaje.jex.http;
exports io.avaje.jex.http.sse;
exports io.avaje.jex.core to io.avaje.jex.staticcontent;
exports io.avaje.jex.core.json;
exports io.avaje.jex.security;
exports io.avaje.jex.spi;
Expand Down