johanhaleby / stub-http

Client library agnostic way to stub HTTP endpoints in Clojure
MIT License
70 stars 10 forks source link

Fixed binary requests handling #20

Closed ABeltramo closed 2 years ago

ABeltramo commented 2 years ago

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:

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:

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.

johanhaleby commented 2 years ago

Really awesome! Great work :) I'll bring it in and make a new release.