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
Expand Up @@ -2,6 +2,7 @@

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

import java.io.IOException;
import java.net.URL;
import java.nio.file.Paths;
import java.util.Map;
Expand Down Expand Up @@ -94,7 +95,7 @@ private void sendURL(Context ctx, String urlPath, URL path) {
return;
}
ctx.rangedWrite(fis);
} catch (final Exception e) {
} catch (final IOException e) {
throw404(ctx.exchange());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ public void write(int byteVal) throws IOException {
public void close() throws IOException {
if (compressedStream != null) {
compressedStream.close();
} else {
originStream.close();
}
originStream.close();
}

private Optional<Compressor> findMatchingCompressor(List<String> acceptedEncoding) {
Expand Down
2 changes: 1 addition & 1 deletion avaje-jex/src/main/java/io/avaje/jex/core/JdkContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ public void write(byte[] bufferBytes, int length) {

@Override
public void write(InputStream is) {
try (var os = outputStream()) {
try (is; var os = outputStream()) {
is.transferTo(os);
} catch (IOException e) {
throw new UncheckedIOException(e);
Expand Down
2 changes: 1 addition & 1 deletion avaje-jex/src/main/java/io/avaje/jex/core/RangeWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static void write(Context ctx, InputStream inputStream, long totalBytes, long ch
ctx.header(Constants.ACCEPT_RANGES, "bytes");
final String rangeHeader = ctx.header(Constants.RANGE);
if (rangeHeader == null) {
ctx.contentLength(totalBytes).write(inputStream);
ctx.write(inputStream);
return;
}
final List<String> requestedRange =
Expand Down
2 changes: 0 additions & 2 deletions avaje-jex/src/test/java/io/avaje/jex/http/RangeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ void downloadingWithoutRequestRange() {
assertThat(response.body().getBytes()).isEqualTo(getInput().readAllBytes());
assertThat(response.statusCode()).isEqualTo(200);

assertThat(response.headers().firstValueAsLong(Constants.CONTENT_LENGTH).orElseThrow())
.isGreaterThan(0L);
assertThat(response.headers().firstValue(Constants.ACCEPT_RANGES).orElseThrow())
.isEqualTo("bytes");
}
Expand Down