req
req copied to clipboard
No way to force encoding of a segment
I'm talking to an HTTP service which requires + in path segments to be encoded. I tried to do this:
newtype RawURLPiece = RawURLPiece Text
instance ToHttpApiData RawURLPiece where
toUrlPiece (RawURLPiece txt) = txt
toEncodedUrlPiece (RawURLPiece txt) = byteString $ encodeUtf8 txt
toQueryParam (RawURLPiece txt) = txt
toEncodedQueryParam (RawURLPiece txt) = byteString $ encodeUtf8 txt
But this still results in the %5B being encoded to %255B if I put it in manually, and of course the library does not encode + to %5B by default. What would you suggest?
With respect to escaping we depend on encodePathSegments from http-types:
https://github.com/mrkkrp/req/blob/master/Network/HTTP/Req.hs#L1212
It does not encode +. There seems to be no solution short of using reqCb and patching paths at that level.