-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Use url::Url instead of http::Uri #382
Comments
I appreciate your concern on this, and I agree that Isahc ought to handle this better. However, this would be a breaking change and would require a 2.0 release at the very least. The problem is that the For an example that demonstrates this better: use isahc::Request; // remember this is just `http::Request`
fn main() {
let request = Request::get("https://sejs-svejbækbiler.dk/")
.body(())
.unwrap(); // panics here with `http::Error(InvalidUri(InvalidUriChar))`
// before any Isahc code even runs
isahc::send(request).unwrap();
} I see only two possible ways that we could handle this:
If we could push for the first approach to get resolved then that would be most ideal, since we could fix this without breaking any existing code out there using Isahc. The second approach may have its own benefits, but also some drawbacks as well as requiring a significant API redesign. When the http crate was first introduced, it was under the hope of being a common "interface crate" that would be generic enough that both HTTP clients and servers could adopt it and allowing the use of interoperable types between otherwise independent crates. This theoretically allows for things such as middleware to be written in an entirely generic way that would allow it to be used with any HTTP client or server instead of being tied to a specific implementation. This sounded like a noble goal, and Isahc was an early adopter those years ago when it was still young. In practice, I am not sure how well this vision materialized and may be worth some investigation. As far as the URI/URL distinction, last time I looked that was a crazy rabbit hole as to which is more technically correct per the HTTP spec. In syntax, URLs are strictly speaking, always absolute, but HTTP allows relative URLs (which is a misnomer), so it is a bit looser than just URLs, but it is stricter than URIs which are very broad indeed. Then there's a mostly semantic debate as to what we call these "URIs as allowed by the HTTP spec", which some opt to call URIs (technically correct but not very precise) and others call URLs (more colloquially used, but not strictly correct). Personally I don't really care about the semantic debate, you can call them URLs or URIs, as long as you're following the HTTP spec. Which |
I've updated hyperium/http#259 pointing here. |
Strictly speaking, it is not possible to implement conversions between I'm not sure that would even help much in this scenario anyway, since |
First of all, replace The best solution for us is to address it from upstream. I submit PR hyperium/http#565 for that. |
Xuanwo's attempt at having a fix accepted in the http crate was not successfull, unfortunately :-( @sagebind, could it be time for a version 2 of isahc, allowing for the API change? |
@troelsarvin I'm not currently planning on making this breaking change, even though technically yes, it could be done as part of version 2. This change would not be insignificant as it would require removing the All I can say is that the changes for version 2 are already planned, and this isn't in that list. |
isahc's reliance on http::Uri makes it cumbersome to work with URLs which have hostnames with non-ASCII characters.
I suggest that isahc switch to using url::Url instead of http::Uri.
Motivations:
The following code shows the current state of affairs in some crates:
The text was updated successfully, but these errors were encountered: