http-rs / http-rs/surf

Invalid url should return an error instead of calling panic

Open
#206 4 comments 5 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.5k
Forks
128
PR merge metrics
No merged PRs in 30d

Description

When building a request, if one provides a invalid url, e.g., `http://foo.bar:---`, the lib panics. I would expect that the parsing error would be returned at some point.

In my use case the application I have may make requests to links fully provided by the user, and since I can't have the hole app shutting down on a user input error I have to validate the url before passing it to surf's client.

Here's a example of one of these `unwrap` calls that I'm talking about:
https://github.com/http-rs/surf/blob/e9ee6fe54f266e0a099905987ef5c2658d813f91/src/client.rs#L140-L143

One possible way that I think would improve this without needing to change the API would be to have such errors stored in the `Request` object and returned when the struct is eventually evaluated into a `Result`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.