Skip to content
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

Be able to create and modify HttpInfo for testing #3062

Open
Will-Low opened this issue Nov 22, 2022 · 0 comments
Open

Be able to create and modify HttpInfo for testing #3062

Will-Low opened this issue Nov 22, 2022 · 0 comments
Labels
C-feature Category: feature. This is adding a new feature.

Comments

@Will-Low
Copy link

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.

@Will-Low Will-Low added the C-feature Category: feature. This is adding a new feature. label Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: feature. This is adding a new feature.
Projects
None yet
Development

No branches or pull requests

1 participant