How can I retrieve the HTTP POST
request body when implementing NanoHTTPDs serve
method?
I\'ve tried to use the getInputStream()
m
I think session.getQueryParameterString();
not work in this case.
If you using POST
, PUT
, you should want to try this code:
Integer contentLength = Integer.parseInt(session.getHeaders().get("content-length"));
byte[] buffer = new byte[contentLength];
session.getInputStream().read(buffer, 0, contentLength);
Log.d("RequestBody: " + new String(buffer));
In fact, I tried IOUtils.toString(inputstream, encoding)
but it cause Timeout exception
!