hyperium / hyperium/http

URI: how to distinguish from invalid port vs no port number

Open
#509 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.4k
Forks
378
Avg merge
1d 21h
Merged PRs (30d)
5

Description

Hey,

I read that default port was rejected in https://github.com/hyperium/http/issues/11.

However, the current API has pub fn port(&self) -> Option<Port<&str>> but it's not possible to
distinguish when invalid port number vs when no port number.
.
Example:

let uri: Uri = "/hello/world".parse().unwrap();
assert!(uri.port().is_none());

let uri: Uri = "/hello/world:-9933".parse().unwrap();
assert!(uri.port().is_none());

Opinions about having pub fn port(&self) -> Result<Option<Port<&str>, Error> or something similar?

Contributor guide

No contributing guide indexed for this repository

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

Start with the Uri::port entry point and the examples in this issue, then read hyperium/http#11 to understand the earlier decision about default ports. Determine how the API should distinguish an absent port from an invalid port, with both "/hello/world" and "/hello/world:-9933" covered as completion cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.