Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Use tokio::spawn in secret_store listener and fix Uri #8373

Merged
merged 5 commits into from
Apr 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions secret_store/src/listener/http_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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>() {
Expand All @@ -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);
Expand Down