Open muttleyxd opened 2 months ago
I have encountered an interesting bug - trying to match a header value which contains a comma , results in incoming header value being parsed as Vec
,
What doesn't work, but I think it should
let mock_server = MockServer::start().await; Mock::given(header("if-modified-since", "Sat, 02 Apr 2005 20:37:00 GMT")) // This is valid RFC2822 .respond_with(ResponseTemplate::new(304)) .expect(1) .mount(&mock_server) .await; // This will return 404 let _result = reqwest::Client::new() .get(mock_server.uri()) .header("if-modified-since", "Sat, 02 Apr 2005 20:37:00 GMT") .send() .await .unwrap() .error_for_status() .unwrap();
Workaround I found:
let mock_server = MockServer::start().await; Mock::given(headers( "if-modified-since", vec!["Sat", "02 Apr 2005 20:37:00 GMT"], )) .respond_with(ResponseTemplate::new(304)) .expect(1) .mount(&mock_server) .await; // Returns 304 let _result = reqwest::Client::new() .get(mock_server.uri()) .header("if-modified-since", "Sat, 02 Apr 2005 20:37:00 GMT") .send() .await .unwrap() .error_for_status() .unwrap(); }
I have prepared a repository with a test that reproduces the issue: https://github.com/muttleyxd/wiremock-header-matcher-bug/blob/master/src/main.rs
I have encountered an interesting bug - trying to match a header value which contains a comma
,
results in incoming header value being parsed as VecWhat doesn't work, but I think it should
Workaround I found:
I have prepared a repository with a test that reproduces the issue: https://github.com/muttleyxd/wiremock-header-matcher-bug/blob/master/src/main.rs