Prevent server Connection from returning same error after calling abrupt shutdown (#352)
This commit is contained in:
committed by
Carl Lerche
parent
8e809c3e0c
commit
a3e59eb7e2
@@ -260,30 +260,29 @@ impl From<Mock<frame::PushPromise>> for SendFrame {
|
||||
|
||||
impl Mock<frame::GoAway> {
|
||||
pub fn protocol_error(self) -> Self {
|
||||
Mock(frame::GoAway::new(
|
||||
self.0.last_stream_id(),
|
||||
frame::Reason::PROTOCOL_ERROR,
|
||||
))
|
||||
self.reason(frame::Reason::PROTOCOL_ERROR)
|
||||
}
|
||||
|
||||
pub fn internal_error(self) -> Self {
|
||||
self.reason(frame::Reason::INTERNAL_ERROR)
|
||||
}
|
||||
|
||||
pub fn flow_control(self) -> Self {
|
||||
Mock(frame::GoAway::new(
|
||||
self.0.last_stream_id(),
|
||||
frame::Reason::FLOW_CONTROL_ERROR,
|
||||
))
|
||||
self.reason(frame::Reason::FLOW_CONTROL_ERROR)
|
||||
}
|
||||
|
||||
pub fn frame_size(self) -> Self {
|
||||
Mock(frame::GoAway::new(
|
||||
self.0.last_stream_id(),
|
||||
frame::Reason::FRAME_SIZE_ERROR,
|
||||
))
|
||||
self.reason(frame::Reason::FRAME_SIZE_ERROR)
|
||||
}
|
||||
|
||||
pub fn no_error(self) -> Self {
|
||||
self.reason(frame::Reason::NO_ERROR)
|
||||
}
|
||||
|
||||
pub fn reason(self, reason: frame::Reason) -> Self {
|
||||
Mock(frame::GoAway::new(
|
||||
self.0.last_stream_id(),
|
||||
frame::Reason::NO_ERROR,
|
||||
reason,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,13 +220,33 @@ fn abrupt_shutdown() {
|
||||
frames::headers(1)
|
||||
.request("POST", "https://example.com/")
|
||||
)
|
||||
.recv_frame(frames::go_away(1))
|
||||
.close();
|
||||
.recv_frame(frames::go_away(1).internal_error())
|
||||
.recv_eof();
|
||||
|
||||
let srv = server::handshake(io).expect("handshake").and_then(|srv| {
|
||||
srv.into_future().unwrap().and_then(|(_, mut srv)| {
|
||||
srv.abrupt_shutdown(Reason::NO_ERROR);
|
||||
srv.into_future().unwrap()
|
||||
srv.into_future().unwrap().and_then(|(item, mut srv)| {
|
||||
let (req, tx) = item.expect("server receives request");
|
||||
|
||||
let req_fut = req
|
||||
.into_body()
|
||||
.concat2()
|
||||
.map(|_| drop(tx))
|
||||
.expect_err("request body should error")
|
||||
.map(|err| {
|
||||
assert_eq!(
|
||||
err.reason(),
|
||||
Some(Reason::INTERNAL_ERROR),
|
||||
"streams should be also error with user's reason",
|
||||
);
|
||||
});
|
||||
|
||||
srv.abrupt_shutdown(Reason::INTERNAL_ERROR);
|
||||
|
||||
let srv_fut = futures::future::poll_fn(move || {
|
||||
srv.poll_close()
|
||||
}).expect("server");
|
||||
|
||||
req_fut.join(srv_fut)
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user