Update jsonrpc dependencies and rewrite dapps to futures. (#6522)
* Bump version. * Fix RPC crate. * Fix BoxFuture in crates. * Compiles and passes tests! * Get rid of .boxed() * Fixing issues with the UI. * Remove minihttp. Support threads. * Reimplement files serving to do it in chunks. * Increase chunk size. * Remove some unecessary copying. * Fix tests. * Fix stratum warning and ipfs todo. * Switch to proper branch of jsonrpc. * Update Cargo.lock. * Update docs. * Include dapps-glue in workspace. * fixed merge artifacts * Fix test compilation.
This commit is contained in:
committed by
Arkadiy Paronyan
parent
492da38d67
commit
e8b418ca03
@@ -19,7 +19,6 @@
|
||||
use jsonrpc_core;
|
||||
use http;
|
||||
use hyper;
|
||||
use minihttp;
|
||||
|
||||
/// HTTP RPC server impl-independent metadata extractor
|
||||
pub trait HttpMetaExtractor: Send + Sync + 'static {
|
||||
@@ -29,24 +28,22 @@ pub trait HttpMetaExtractor: Send + Sync + 'static {
|
||||
fn read_metadata(&self, origin: Option<String>, user_agent: Option<String>, dapps_origin: Option<String>) -> Self::Metadata;
|
||||
}
|
||||
|
||||
pub struct HyperMetaExtractor<T> {
|
||||
pub struct MetaExtractor<T> {
|
||||
extractor: T,
|
||||
}
|
||||
|
||||
impl<T> HyperMetaExtractor<T> {
|
||||
impl<T> MetaExtractor<T> {
|
||||
pub fn new(extractor: T) -> Self {
|
||||
HyperMetaExtractor {
|
||||
extractor: extractor,
|
||||
}
|
||||
MetaExtractor { extractor }
|
||||
}
|
||||
}
|
||||
|
||||
impl<M, T> http::MetaExtractor<M> for HyperMetaExtractor<T> where
|
||||
impl<M, T> http::MetaExtractor<M> for MetaExtractor<T> where
|
||||
T: HttpMetaExtractor<Metadata = M>,
|
||||
M: jsonrpc_core::Metadata,
|
||||
{
|
||||
fn read_metadata(&self, req: &hyper::server::Request<hyper::net::HttpStream>) -> M {
|
||||
let as_string = |header: Option<&http::request_response::header::Raw>| header
|
||||
fn read_metadata(&self, req: &hyper::server::Request) -> M {
|
||||
let as_string = |header: Option<&hyper::header::Raw>| header
|
||||
.and_then(|raw| raw.one())
|
||||
.map(|raw| String::from_utf8_lossy(raw).into_owned());
|
||||
|
||||
@@ -56,28 +53,3 @@ impl<M, T> http::MetaExtractor<M> for HyperMetaExtractor<T> where
|
||||
self.extractor.read_metadata(origin, user_agent, dapps_origin)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MiniMetaExtractor<T> {
|
||||
extractor: T,
|
||||
}
|
||||
|
||||
impl<T> MiniMetaExtractor<T> {
|
||||
pub fn new(extractor: T) -> Self {
|
||||
MiniMetaExtractor {
|
||||
extractor: extractor,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<M, T> minihttp::MetaExtractor<M> for MiniMetaExtractor<T> where
|
||||
T: HttpMetaExtractor<Metadata = M>,
|
||||
M: jsonrpc_core::Metadata,
|
||||
{
|
||||
fn read_metadata(&self, req: &minihttp::Req) -> M {
|
||||
let origin = req.header("origin").map(|h| h.to_owned());
|
||||
let user_agent = req.header("user-agent").map(|h| h.to_owned());
|
||||
let dapps_origin = req.header("x-parity-origin").map(|h| h.to_owned());
|
||||
|
||||
self.extractor.read_metadata(origin, user_agent, dapps_origin)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user