hyperium / hyperium/hyper

Be able to create and modify `HttpInfo` for testing

Open
#3,062 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I've run into the case several times when unit testing where I need to return a Response whose extensions contain an HttpInfo. However, since the fields on HttpInfo are private, I am unable to create one.

I would like to see a way to create a new HttpInfo, either by making the fields public, adding setters, or by adding a constructor. Since there are already getter methods, I think it may make most sense to:

  1. Add a constructor to create a new HttpInfo.
  2. Add setters for the remote and local addresses.

Note that it is already possible to get a mutable reference to HttpInfo via:

let mut response = Response::new(Body::empty());
let http_info = response.extensions_mut().get_mut::<HttpInfo>().unwrap();

but without setters, there is nothing you can do with it.

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 the HttpInfo definition and its existing getter methods, then inspect how it is stored in Response extensions. Add the requested construction and mutation API so tests can create and modify HttpInfo values, and verify that the existing Response extension access pattern supports those values.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, testing
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.