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 easy function for (Text -> m Request) without taking method in the string #497

Open
lf- opened this issue Dec 12, 2022 · 0 comments
Open

Comments

@lf-
Copy link

lf- commented Dec 12, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant