From 9783f8c7f425f41757837a7f4ad4966bf9575143 Mon Sep 17 00:00:00 2001 From: Feng Hao Date: Sat, 16 Jun 2018 22:23:33 +0800 Subject: [PATCH] fix query string for POST request not being set correctly #363 --- .../java/org/nanohttpd/protocols/http/HTTPSession.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 e8df9338..629940db 100644 --- a/core/src/main/java/org/nanohttpd/protocols/http/HTTPSession.java +++ b/core/src/main/java/org/nanohttpd/protocols/http/HTTPSession.java @@ -157,12 +157,15 @@ private void decodeHeader(BufferedReader in, Map pre, Map= 0) { - 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); } + // If there's another token, its protocol version, // followed by HTTP headers. // NOTE: this now forces header names lower case since they are @@ -308,11 +311,9 @@ private int scipOverNewLine(byte[] partHeaderBuff, int index) { */ private void decodeParms(String parms, Map> p) { if (parms == null) { - this.queryParameterString = ""; return; } - this.queryParameterString = parms; StringTokenizer st = new StringTokenizer(parms, "&"); while (st.hasMoreTokens()) { String e = st.nextToken();