diff --git a/build.gradle b/build.gradle index 382fd6a8..ebc0578a 100644 --- a/build.gradle +++ b/build.gradle @@ -20,6 +20,6 @@ subprojects { } } -task wrapper(type: Wrapper) { +wrapper { gradleVersion = "4.4.1" } diff --git a/core/src/main/java/org/nanohttpd/protocols/http/HTTPSession.java b/core/src/main/java/org/nanohttpd/protocols/http/HTTPSession.java index 80456b06..e41579f1 100644 --- a/core/src/main/java/org/nanohttpd/protocols/http/HTTPSession.java +++ b/core/src/main/java/org/nanohttpd/protocols/http/HTTPSession.java @@ -154,9 +154,12 @@ private void decodeHeader(BufferedReader in, Map pre, Map= 0) { - decodeParms(uri.substring(qmi + 1), parms); +// decodeParms(uri.substring(qmi + 1), parms); + queryParameterString = uri.substring(qmi + 1); + decodeParms(queryParameterString, parms); uri = NanoHTTPD.decodePercent(uri.substring(0, qmi)); } else { + queryParameterString = ""; uri = NanoHTTPD.decodePercent(uri); } @@ -305,11 +308,11 @@ private int scipOverNewLine(byte[] partHeaderBuff, int index) { */ private void decodeParms(String parms, Map> p) { if (parms == null) { - this.queryParameterString = ""; +// this.queryParameterString = ""; return; } - this.queryParameterString = parms; +// this.queryParameterString = parms; StringTokenizer st = new StringTokenizer(parms, "&"); while (st.hasMoreTokens()) { String e = st.nextToken(); @@ -456,6 +459,9 @@ public void execute() throws IOException { NanoHTTPD.safeClose(this.outputStream); } finally { NanoHTTPD.safeClose(r); + if(r.getRequestMethod() == Method.POST) { + NanoHTTPD.safeClose(this.inputStream); + } this.tempFileManager.clear(); } } diff --git a/core/src/main/java/org/nanohttpd/protocols/http/response/Response.java b/core/src/main/java/org/nanohttpd/protocols/http/response/Response.java index 8d1b532f..b49e86a7 100644 --- a/core/src/main/java/org/nanohttpd/protocols/http/response/Response.java +++ b/core/src/main/java/org/nanohttpd/protocols/http/response/Response.java @@ -349,7 +349,13 @@ private void sendBody(OutputStream outputStream, long pending) throws IOExceptio long bytesToRead = sendEverything ? BUFFER_SIZE : Math.min(pending, BUFFER_SIZE); int read = this.data.read(buff, 0, (int) bytesToRead); if (read <= 0) { - break; + if(this.getRequestMethod() == Method.POST) { + break; + } + else { + Thread.sleep(1000); + continue; + } } try { outputStream.write(buff, 0, read);