Hello
I upgraded from actix-web-3 to actix-web-4.0.0-rc.2 - which worked fine. When testing I encountered an issue I don't really come up with a solution. How am I supposed to add a HTTP-header?
I'm getting a trait not satified error:
error[E0277]: the trait bound `HeaderMap: actix_http::header::Header` is not satisfied
--> src/main.rs:549:40
|
549 | .insert_header(hm)
| ------------- ^^ the trait `actix_http::header::Header` is not implemented for `HeaderMap`
| |
| required by a bound introduced by this call
|
= note: required because of the requirements on the impl of `TryIntoHeaderPair` for `HeaderMap`
note: required by a bound in `actix_web::test::TestRequest::insert_header`
--> /home/doerig/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-4.0.0-rc.2/src/test/test_request.rs:134:49
|
134 | pub fn insert_header(mut self, header: impl TryIntoHeaderPair) -> Self {
| ^^^^^^^^^^^^^^^^^ required by this bound in `actix_web::test::TestRequest::insert_header`
My toml looks like this:
actix-multipart = "0.4.0-beta.12"
actix-rt = "2"
actix-web = "4.0.0-rc.2"
actix-http = "3.0.0-rc.1"
The code in the test section looks like this:
use actix_web::{http::StatusCode, test, App};
use actix_http::header::map::HeaderMap;
use actix_http::header::{Header, HeaderName, HeaderValue};
// big snip....
let mut hm: HeaderMap = HeaderMap::new();
hm.insert(actix_web::http::header::CONTENT_TYPE, HeaderValue::from_static("application/json"));
hm.insert(actix_web::http::header::AUTHORIZATION, HeaderValue::from_static(&format!("Basic {}", sessiontoken)));
test::TestRequest::post()
.uri(uri)
.append_header(hm)
.send_request(&mut app)
.await
I just don't get it how to pass headers to test request except implementing this trait by myself.
Thanks
Stefan