Add client support for server push (#314)

This patch exposes push promises to the client API.

Closes #252
This commit is contained in:
Michael Beaumont
2018-10-16 21:51:08 +02:00
committed by Carl Lerche
parent 6d8554a23c
commit 6b23542a55
11 changed files with 397 additions and 76 deletions

View File

@@ -220,6 +220,18 @@ impl Mock<frame::PushPromise> {
Mock(frame)
}
pub fn field<K, V>(self, key: K, value: V) -> Self
where
K: HttpTryInto<http::header::HeaderName>,
V: HttpTryInto<http::header::HeaderValue>,
{
let (id, promised, pseudo, mut fields) = self.into_parts();
fields.insert(key.try_into().unwrap(), value.try_into().unwrap());
let frame = frame::PushPromise::new(id, promised, pseudo, fields);
Mock(frame)
}
fn into_parts(self) -> (StreamId, StreamId, frame::Pseudo, HeaderMap) {
assert!(self.0.is_end_headers(), "unset eoh will be lost");
let id = self.0.stream_id();