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 hyper::server::Http;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
use tokio::executor::current_thread;
|
use tokio;
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
use tokio_service::Service;
|
use tokio_service::Service;
|
||||||
@ -104,9 +104,7 @@ impl KeyServerHttpListener {
|
|||||||
warn!("Key server handler error: {:?}", e);
|
warn!("Key server handler error: {:?}", e);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Change this to tokio::spawn once hyper is Send.
|
tokio::spawn(serve)
|
||||||
current_thread::spawn(serve);
|
|
||||||
future::ok(())
|
|
||||||
});
|
});
|
||||||
|
|
||||||
runtime.spawn(server);
|
runtime.spawn(server);
|
||||||
@ -207,7 +205,7 @@ impl Service for KeyServerHttpHandler {
|
|||||||
type Request = HttpRequest;
|
type Request = HttpRequest;
|
||||||
type Response = HttpResponse;
|
type Response = HttpResponse;
|
||||||
type Error = hyper::Error;
|
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 {
|
fn call(&self, req: HttpRequest) -> Self::Future {
|
||||||
if req.headers().has::<header::Origin>() {
|
if req.headers().has::<header::Origin>() {
|
||||||
@ -222,7 +220,7 @@ impl Service for KeyServerHttpHandler {
|
|||||||
|
|
||||||
Box::new(req.body().concat2().map(move |body| {
|
Box::new(req.body().concat2().map(move |body| {
|
||||||
let path = req_uri.path().to_string();
|
let path = req_uri.path().to_string();
|
||||||
if req_uri.is_absolute() {
|
if path.starts_with("/") {
|
||||||
this.process(req_method, req_uri, &path, &body)
|
this.process(req_method, req_uri, &path, &body)
|
||||||
} else {
|
} else {
|
||||||
warn!(target: "secretstore", "Ignoring invalid {}-request {}", req_method, req_uri);
|
warn!(target: "secretstore", "Ignoring invalid {}-request {}", req_method, req_uri);
|
||||||
|
Loading…
Reference in New Issue
Block a user