Open yurijmikhalevich opened 3 years ago
Looks like decodeParams
should be called here unconditionally:
https://github.com/NanoHttpd/nanohttpd/blob/efb2ebf85a2b06f7c508aba9eaad5377e3a01e81/core/src/main/java/org/nanohttpd/protocols/http/HTTPSession.java#L156-L157
Since decodeParams
can handle missing params well on its own: https://github.com/NanoHttpd/nanohttpd/blob/efb2ebf85a2b06f7c508aba9eaad5377e3a01e81/core/src/main/java/org/nanohttpd/protocols/http/HTTPSession.java#L306-L310
Alternatively, we can this.queryParameterString = "";
before the check on L156 in HTTPSession.java
.
If anyone stumbles upon this, you can work around this by nullifying session.queryParameterString
after you've processed the request with the following code:
Field queryParameterStringField = session.getClass().getDeclaredField("queryParameterString");
queryParameterStringField.setAccessible(true);
queryParameterStringField.set(session, null);
Steps to reproduce:
GET /something?param=value
to the NanoHTTPD serverGET /whatever
to the NanoHTTPD serversession.getQueryParameterString()
will returnparam=value
for both requests.