surf
surf copied to clipboard
Crash when malformed uri
let res = surf::get("abc").recv_string(data).await;
As above, this will cause the program to crash.
Hi, thanks for raising! I've been thinking of how to solve this, and what we probably want is to be able to take TryInto<Url> as the type parameter. For that purpose I've filed:
- https://github.com/servo/rust-url/issues/568
- https://github.com/servo/rust-url/pull/569
This would require the usage to:
let res = surf::get("abc")?.recv_string(data).await;
Which would provide graceful error handling rather than directly panicking.
However the solution to your exact issue is to use a fullly-formed url. E.g.
let res = surf::get("http://my-domain.com/abc").recv_string(data).await;
Do you still want to take TryInto<Url> as parameters? I think this also applies to other methods. I could help a PR if this is what it prefers to be.
It looks like TryInto<Url> support is still waiting for a new release of the url crate.