Skip to content

Commit

Permalink
server: remove dependency http (paritytech#1037)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasad1 authored and Tengiz Sharafiev committed Mar 3, 2023
1 parent 464b64f commit 80ab47c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
1 change: 0 additions & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ soketto = { version = "0.7.1", features = ["http"] }
tokio = { version = "1.16", features = ["net", "rt-multi-thread", "macros", "time"] }
tokio-util = { version = "0.7", features = ["compat"] }
tokio-stream = "0.1.7"
http = "0.2.7"
hyper = { version = "0.14", features = ["server", "http1", "http2"] }
tower = "0.4.13"

Expand Down
5 changes: 2 additions & 3 deletions server/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
use std::net::SocketAddr;

/// HTTP request.
pub type HttpRequest = http::Request<Body>;
pub use http::HeaderMap as Headers;
pub use hyper::Body;
pub type HttpRequest = hyper::Request<Body>;
pub use hyper::{Body, HeaderMap as Headers};
pub use jsonrpsee_types::Params;

/// The type JSON-RPC v2 call, it can be a subscription, method call or unknown.
Expand Down
10 changes: 4 additions & 6 deletions server/src/tests/shared.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use crate::tests::helpers::{init_logger, server_with_handles};
use http::StatusCode;
use hyper::StatusCode;
use jsonrpsee_core::Error;
use jsonrpsee_test_utils::{
helpers::{http_request, ok_response, to_http_uri},
mocks::{Id, WebSocketTestClient, WebSocketTestError},
TimeoutFutureExt,
};
use jsonrpsee_test_utils::helpers::{http_request, ok_response, to_http_uri};
use jsonrpsee_test_utils::mocks::{Id, WebSocketTestClient, WebSocketTestError};
use jsonrpsee_test_utils::TimeoutFutureExt;
use std::time::Duration;

#[tokio::test]
Expand Down
7 changes: 3 additions & 4 deletions server/src/transport/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::logger::{self, Logger, TransportProtocol};

use futures_util::future::Either;
use futures_util::stream::{FuturesOrdered, StreamExt};
use http::Method;
use hyper::Method;
use jsonrpsee_core::error::GenericTransportError;
use jsonrpsee_core::http_helpers::read_body;
use jsonrpsee_core::server::helpers::{prepare_error, BatchResponse, BatchResponseBuilder, MethodResponse};
Expand All @@ -23,7 +23,7 @@ type Notif<'a> = Notification<'a, Option<&'a JsonRawValue>>;

/// Checks that content type of received request is valid for JSON-RPC.
pub(crate) fn content_type_is_json(request: &hyper::Request<hyper::Body>) -> bool {
is_json(request.headers().get(http::header::CONTENT_TYPE))
is_json(request.headers().get(hyper::header::CONTENT_TYPE))
}

/// Returns true if the `content_type` header indicates a valid JSON message.
Expand Down Expand Up @@ -344,8 +344,7 @@ pub(crate) async fn handle_request<L: Logger>(
}

pub(crate) mod response {
use jsonrpsee_types::error::reject_too_big_request;
use jsonrpsee_types::error::{ErrorCode, ErrorResponse};
use jsonrpsee_types::error::{reject_too_big_request, ErrorCode, ErrorResponse};
use jsonrpsee_types::Id;

const JSON: &str = "application/json; charset=utf-8";
Expand Down

0 comments on commit 80ab47c

Please sign in to comment.