Skip to content
Merged
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
26 changes: 13 additions & 13 deletions pippo-core/src/main/java/ro/pippo/core/gzip/GZipResponseStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ public void close() throws IOException {
if (closed) {
throw new IOException("This output stream has already been closed");
}
try (ServletOutputStream outputStream = response.getOutputStream()) {
gzipOutputStream.finish();

gzipOutputStream.finish();
byte[] bytes = byteArrayOutputStream.toByteArray();

byte[] bytes = byteArrayOutputStream.toByteArray();
response.addHeader("Content-Length", Integer.toString(bytes.length));
response.addHeader("Content-Encoding", "gzip");

response.addHeader("Content-Length", Integer.toString(bytes.length));
response.addHeader("Content-Encoding", "gzip");

ServletOutputStream outputStream = response.getOutputStream();
outputStream.write(bytes);
outputStream.flush();
outputStream.close();

closed = true;
outputStream.write(bytes);
outputStream.flush();
} finally {
gzipOutputStream.close();
closed = true;
}
}

@Override
Expand All @@ -81,12 +81,12 @@ public void write(int b) throws IOException {
}

@Override
public void write(byte b[]) throws IOException {
public void write(byte[] b) throws IOException {
write(b, 0, b.length);
}

@Override
public void write(byte b[], int off, int len) throws IOException {
public void write(byte[] b, int off, int len) throws IOException {
if (closed) {
throw new IOException("Cannot write to a closed output stream");
}
Expand Down