I saw that the library wasn't working with binary (byte arrays) payloads, while the underlying NanoHTTPD does support them (kinda, see below), so here's a pull request to fix it!
Other minor changes:
Changed a few single branch if to when
Moved a couple of docstrings in the right place (before the arguments)
Added a simple unit test for this new capability
Disclaimer
While this is enough to fix the exception, and it'll work easily for a roundtrip of String -> Bytes -> String it can easily break when doing Bytes -> String -> Bytes for two reasons:
Some bytes can't be represented in the default UTF-8 encoding
Unfortunately, not only it's always casted as a String, but it's also trimmed, here (when calling (.parseBody session body-map)).
This may result in a different byte array depending on the payload.
For this problematic payloads I couldn't find a way to properly check the request payload, the response was correctly returned as a byte array instead; no problem there.
Hello there! π
I saw that the library wasn't working with binary (byte arrays) payloads, while the underlying
NanoHTTPD
does support them (kinda, see below), so here's a pull request to fix it!Other minor changes:
if
towhen
Disclaimer
While this is enough to fix the exception, and it'll work easily for a roundtrip of
String -> Bytes -> String
it can easily break when doingBytes -> String -> Bytes
for two reasons:UTF-8
encodingISO-8859-1
instead, see stackoverflow#15925458(.parseBody session body-map)
).For this problematic payloads I couldn't find a way to properly check the request payload, the response was correctly returned as a byte array instead; no problem there.