1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-26 06:57:43 +02:00

on_connect result isnt added to request extensions for http2 requests #1009

This commit is contained in:
Nikolay Kim
2019-09-01 13:15:02 +06:00
parent bae29897d6
commit 63ddd30ee4
7 changed files with 64 additions and 6 deletions

View File

@ -11,6 +11,7 @@ use futures::stream::{once, Stream};
use regex::Regex;
use tokio_timer::sleep;
use actix_http::httpmessage::HttpMessage;
use actix_http::{
body, error, http, http::header, Error, HttpService, KeepAlive, Request, Response,
};
@ -602,3 +603,18 @@ fn test_h1_service_error() {
let bytes = srv.load_body(response).unwrap();
assert_eq!(bytes, Bytes::from_static(b"error"));
}
#[test]
fn test_h1_on_connect() {
let mut srv = TestServer::new(|| {
HttpService::build()
.on_connect(|_| 10usize)
.h1(|req: Request| {
assert!(req.extensions().contains::<usize>());
future::ok::<_, ()>(Response::Ok().finish())
})
});
let response = srv.block_on(srv.get("/").send()).unwrap();
assert!(response.status().is_success());
}