-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fix rewrite of User-Agent header #9707
Conversation
@vbrvk thank you! would it be possible to have a unit test to prevent regressions, in this way could also better understand the issue and solution too |
@grandizzy actually I was thinking about tests but it is not possible to retrieve headers of request without firing it, so local server start required. I thought it is overkill for such little thing. You OK with such approach or you suggesting more simple test? #[tokio::test]
async fn test_headers() {
let transport = RuntimeTransportBuilder::new(Url::parse("127.0.0.1").unwrap())
.with_headers(vec!["User-Agent: test-agent".to_string()])
.build();
let inner = transport.connect_http().await.unwrap();
match inner {
InnerTransport::Http(http) => {
let client = http.client();
let req = client.get("/").build().unwrap();
let actual_headers = req.headers();
// aseert here
}
_ => unreachable!(),
}
} |
that would be better than nothing, though if we need to start an anvil instance and then call cast or forge against we have several examples as here foundry/crates/cast/tests/cli/main.rs Line 1760 in 00c944b
|
@grandizzy added test So if fix not present, then test fails with
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Motivation
For now passed
User-Agent
header is rewritten tofoundry/version
, but it should notSolution
Fix header existence check condition (
HeaderName
is lowercased and do not contains:
)