http-client icon indicating copy to clipboard operation
http-client copied to clipboard

No easy function for (Text -> m Request) without taking method in the string

Open lf- opened this issue 3 years ago • 0 comments

parseRequest is cool, but it optionally takes a method before the URL, which makes the "easy thing" allow for changing the method unexpectedly if given user input. This is surprising.

I wrote something like this:

    parseRequest' :: MonadThrow m => Text -> m Request
    parseRequest' uri =
      requestFromURI
        =<< maybe
          (throwM . stringException $ "bad URI")
          pure
          (parseURI (unpack uri))

This is fine, but it's surprising that there's not a version of this in http-client, which probably allows for accidentally messing with methods in programs that don't check the URLs that go into parseRequest.

lf- avatar Dec 12 '22 19:12 lf-