tests: reduce boilerplate of sending GET requests
This adds a `SendRequestExt` trait to h2-support, with a `get` method that does a lot of the repeated request building stuff many test cases were doing. As a first step, the cleans up stream_states tests to use it.
This commit is contained in:
		| @@ -72,20 +72,11 @@ pub trait FutureExt: Future { | ||||
|     /// | ||||
|     /// This allows the executor to poll other futures before trying this one | ||||
|     /// again. | ||||
|     fn yield_once(self) -> Box<Future<Item = Self::Item, Error = Self::Error>> | ||||
|     fn yield_once(self) -> Box<dyn Future<Item = Self::Item, Error = Self::Error>> | ||||
|     where | ||||
|         Self: Future + Sized + 'static, | ||||
|     { | ||||
|         let mut ready = false; | ||||
|         Box::new(::futures::future::poll_fn(move || { | ||||
|             if ready { | ||||
|                 Ok::<_, ()>(().into()) | ||||
|             } else { | ||||
|                 ready = true; | ||||
|                 ::futures::task::current().notify(); | ||||
|                 Ok(::futures::Async::NotReady) | ||||
|             } | ||||
|         }).then(|_| self)) | ||||
|         Box::new(super::util::yield_once().then(move |_| self)) | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user