Use tokio::spawn in secret_store listener and fix Uri (#8373)
* Directly wait for future to resolve in a threadpool * Ignore return value * Use path.starts_with instead of req_uri.is_absolute The later now means something else in hyper 0.11.. * Use tokio::spawn * typo: remove accidential unsafe impl
This commit is contained in:
parent
897a94641e
commit
f6998cb04e
@ -20,7 +20,7 @@ use hyper::{self, header, Chunk, Uri, Request as HttpRequest, Response as HttpRe
|
||||
use hyper::server::Http;
|
||||
use serde::Serialize;
|
||||
use serde_json;
|
||||
use tokio::executor::current_thread;
|
||||
use tokio;
|
||||
use tokio::net::TcpListener;
|
||||
use tokio::runtime::Runtime;
|
||||
use tokio_service::Service;
|
||||
@ -104,9 +104,7 @@ impl KeyServerHttpListener {
|
||||
warn!("Key server handler error: {:?}", e);
|
||||
});
|
||||
|
||||
// TODO: Change this to tokio::spawn once hyper is Send.
|
||||
current_thread::spawn(serve);
|
||||
future::ok(())
|
||||
tokio::spawn(serve)
|
||||
});
|
||||
|
||||
runtime.spawn(server);
|
||||
@ -207,7 +205,7 @@ impl Service for KeyServerHttpHandler {
|
||||
type Request = HttpRequest;
|
||||
type Response = HttpResponse;
|
||||
type Error = hyper::Error;
|
||||
type Future = Box<Future<Item=Self::Response, Error=Self::Error>>;
|
||||
type Future = Box<Future<Item=Self::Response, Error=Self::Error> + Send>;
|
||||
|
||||
fn call(&self, req: HttpRequest) -> Self::Future {
|
||||
if req.headers().has::<header::Origin>() {
|
||||
@ -222,7 +220,7 @@ impl Service for KeyServerHttpHandler {
|
||||
|
||||
Box::new(req.body().concat2().map(move |body| {
|
||||
let path = req_uri.path().to_string();
|
||||
if req_uri.is_absolute() {
|
||||
if path.starts_with("/") {
|
||||
this.process(req_method, req_uri, &path, &body)
|
||||
} else {
|
||||
warn!(target: "secretstore", "Ignoring invalid {}-request {}", req_method, req_uri);
|
||||
|
Loading…
Reference in New Issue
Block a user