hyperium / hyperium/hyper

hyper::Uri does not seem to parse URIs that do not have a host field

Open
#2,445 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
16.3k
Forks
1.8k
Avg merge
1d 22h
Merged PRs (30d)
14

Description

The Uri parser does not appear to be able to handle URIs that do not provide a host field.

I realize that the hyper::Uri module might not be intended to provide a complete URI implementation, so maybe just a mention of this in the docs is good enough.

Anyway, here's the issue: Omitting a host field causes the parser to fail with InvalidFormat.

For example, RFC 8089 defines the file schema, allowing local files to omit host. Both file:/// and file:/ are allowed. RFC 3986 does not require a host field after a scheme. But this test fails on the from_str().

    #[test]
    fn should_parse_file_scheme() {
        let uri = hyper::Uri::from_str("file:///foo/bar").expect("Should parse URI with no host");
        assert!(uri.host().is_none());
    }

Tested on Hyper 0.14.4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate hyper::Uri's from_str parser and its URI parsing tests, then reproduce the failure with file:///foo/bar and file:/ URIs. Determine whether the intended outcome is parser support or a documentation note; done means the chosen behavior is covered by a test or clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.