diff --git a/pom.xml b/pom.xml
index 0f61b52..f1c24b0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.kttdevelopment
simplehttpserver
- DEVELOPMENT
+ 03.00.01
jar
diff --git a/src/main/java/com/kttdevelopment/simplehttpserver/SimpleHttpExchangeImpl.java b/src/main/java/com/kttdevelopment/simplehttpserver/SimpleHttpExchangeImpl.java
index f705cb4..218ce10 100644
--- a/src/main/java/com/kttdevelopment/simplehttpserver/SimpleHttpExchangeImpl.java
+++ b/src/main/java/com/kttdevelopment/simplehttpserver/SimpleHttpExchangeImpl.java
@@ -122,12 +122,10 @@ static SimpleHttpExchange createSimpleHttpExchange(final HttpExchange exchange){
//
String OUT;
- final InputStream IN = httpExchange.getRequestBody();
- try(final Scanner scanner = new Scanner(IN,StandardCharsets.UTF_8)){
+ try(InputStream IN = httpExchange.getRequestBody(); final Scanner scanner = new Scanner(IN, StandardCharsets.UTF_8)){
OUT = scanner.useDelimiter("\\A").next();
- IN.close();
- }catch(IOException | NoSuchElementException e){
+ }catch(final IOException | NoSuchElementException ignored){
OUT = null;
}
@@ -361,14 +359,17 @@ public void send(final byte[] response, final int responseCode, final boolean gz
exchange.getResponseHeaders().set("Content-Encoding","gzip");
exchange.getResponseHeaders().set("Connection","keep-alive");
sendResponseHeaders(responseCode, 0);
- GZIPOutputStream OUT = new GZIPOutputStream(exchange.getResponseBody());
- OUT.write(response);
- OUT.finish();
+ try(GZIPOutputStream OUT = new GZIPOutputStream(exchange.getResponseBody())){
+ OUT.write(response);
+ OUT.finish();
+ OUT.flush();
+ }
}else{
sendResponseHeaders(responseCode,response.length);
- final OutputStream OUT = exchange.getResponseBody();
- OUT.write(response);
- OUT.flush();
+ try(final OutputStream OUT = exchange.getResponseBody()){
+ OUT.write(response);
+ OUT.flush();
+ }
}
}