Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: remove dependency http #1037

Merged
merged 1 commit into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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
10 changes: 4 additions & 6 deletions server/src/transport/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ 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::{batch_response_error, prepare_error, BatchResponseBuilder, MethodResponse};
use jsonrpsee_core::server::rpc_module::MethodCallback;
use jsonrpsee_core::server::rpc_module::Methods;
use jsonrpsee_core::server::rpc_module::{MethodCallback, Methods};
use jsonrpsee_core::tracing::{rx_log_from_json, tx_log_from_str};
use jsonrpsee_core::JsonRawValue;
use jsonrpsee_types::error::{ErrorCode, BATCHES_NOT_SUPPORTED_CODE, BATCHES_NOT_SUPPORTED_MSG};
Expand All @@ -23,7 +22,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 @@ -312,8 +311,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