Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to force encoding of a segment #170

Closed
singpolyma opened this issue May 29, 2024 · 1 comment
Closed

No way to force encoding of a segment #170

singpolyma opened this issue May 29, 2024 · 1 comment
Labels

Comments

@singpolyma
Copy link

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?

@mrkkrp
Copy link
Owner

mrkkrp commented May 30, 2024

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.

@mrkkrp mrkkrp closed this as completed Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants