Uri Builder path change broke parsing and reconstructing the Uri with empty path
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 62/100
Research direction
Start with the Uri::builder path_and_query handling shown in the issue and compare its behavior between http v1.4.0 and v1.4.1. Add a regression test for rebuilding a Uri with an empty path, then run the relevant Uri builder and parsing tests to confirm the example succeeds.
Written by the indexing model from the issue text.
Description
Version
http v1.4.1
Platform
Linux 6.8.0-111-generic Ubuntu 24.04
Summary
Uri Builder path change broke parsing and reconstructing the Uri with empty path.
In example below the path returns empty string.
This used to work fine to sanitize/cleanup a provided Url string, which I think is a common pattern people use.
As Uri.path() always returns a string and not an Option<String> its not intuitive that this stops working.
Also what is a bit annoying is that this broke in a patch update version.
Took me a while to figure out that an auto update of this dependency broke this behavior.
Code Sample
let uri = Uri::from_str("example.com")?;
let final_uri = Uri::builder()
.scheme(uri.scheme_str().unwrap_or("https"))
.authority(uri.authority()?.as_str())
.path_and_query(uri.path())
.build();
Expected Behavior
In v1.4.0 this used to work.
final_uri = Ok(Uri(...))
Actual Behavior
Since v1.4.1 this fails now.
final_uri = Err(http::Error(InvalidUri(Empty)))
Additional Context
If this is just intended and works as designed then feel free to close this.
Workaround I needed to add:
let path = if !path.starts_with("/") {
"/".to_string() + path
} else {
path.to_string()
};
- Dominant language
- Rust
- Stars
- 1.4k
- Forks
- 378
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 5
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from hyperium/http
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
stratum-mining/stratum#2404 ·
-
bug ci good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100