Skip to content

Commit

Permalink
chore(deps): use http crate for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
amitksingh1490 committed Sep 29, 2024
1 parent c4e0901 commit f20bd2f
Show file tree
Hide file tree
Showing 58 changed files with 152 additions and 134 deletions.
7 changes: 6 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ async-graphql = { version = "7.0.9" }
futures-util = { version = "0.3.30" }
indexmap = "2.2.6"
headers = "0.3.9" # previous version until hyper is updated to 1+
http = "0.2.12" # previous version until hyper is updated to 1+
insta = { version = "1.38.0", features = ["json"] }
tokio = { version = "1.37.0", features = ["rt", "time"] }
reqwest = { version = "0.11", features = [
Expand Down Expand Up @@ -139,7 +140,8 @@ opentelemetry-prometheus = "0.16.0"
phonenumber = "0.3.4"
chrono = "0.4.38"
async-graphql-extension-apollo-tracing = { version = "3.2.15" }
headers = { workspace = true } # previous version until hyper is updated to 1+
headers = { workspace = true }
http = { workspace = true }
mime = "0.3.17"
htpasswd-verify = { version = "0.3.0", git = "https://github.com/twistedfall/htpasswd-verify", rev = "ff14703083cbd639f7d05622b398926f3e718d61" } # fork version that is wasm compatible
jsonwebtoken = "9.3.0"
Expand Down
2 changes: 1 addition & 1 deletion benches/from_json_bench.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use criterion::Criterion;
use hyper::Method;
use http::Method;
use serde_json::Value;
use tailcall::cli::runtime::NativeHttp;
use tailcall::core::generator::{Generator, Input};
Expand Down
2 changes: 1 addition & 1 deletion benches/handle_request_bench.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use criterion::Criterion;
use hyper::Request;
use http::Request;
use tailcall::cli::server::server_config::ServerConfig;
use tailcall::core::async_graphql_hyper::GraphQLRequest;
use tailcall::core::blueprint::Blueprint;
Expand Down
2 changes: 1 addition & 1 deletion benches/http_execute_bench.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use criterion::Criterion;
use hyper::Method;
use http::Method;
use tailcall::cli::runtime::NativeHttp;
use tailcall::core::blueprint::Blueprint;
use tailcall::core::HttpIO;
Expand Down
2 changes: 1 addition & 1 deletion benches/impl_path_string_for_evaluation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::time::Duration;
use async_graphql::{Name, Value};
use async_trait::async_trait;
use criterion::{BenchmarkId, Criterion};
use headers::{HeaderMap, HeaderValue};
use http::header::{HeaderMap, HeaderValue};
use http_cache_reqwest::{Cache, CacheMode, HttpCache, HttpCacheOptions};
use hyper::body::Bytes;
use indexmap::IndexMap;
Expand Down
2 changes: 1 addition & 1 deletion benches/request_template_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::borrow::Cow;

use criterion::{black_box, Criterion};
use derive_setters::Setters;
use headers::HeaderMap;
use http::header::HeaderMap;
use serde_json::json;
use tailcall::core::endpoint::Endpoint;
use tailcall::core::has_headers::HasHeaders;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/generator/generator.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fs;
use std::path::Path;

use headers::{HeaderMap, HeaderName, HeaderValue};
use http::header::{HeaderMap, HeaderName, HeaderValue};
use inquire::Confirm;
use pathdiff::diff_paths;

Expand Down
6 changes: 3 additions & 3 deletions src/cli/javascript/codec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;
use std::str::FromStr;

use headers::{HeaderName, HeaderValue};
use http::header::{HeaderName, HeaderValue};
use rquickjs::{FromJs, IntoJs};

use super::create_header_map;
Expand Down Expand Up @@ -205,7 +205,7 @@ mod test {
use std::collections::BTreeMap;

use anyhow::Result;
use headers::{HeaderMap, HeaderName, HeaderValue};
use http::header::{HeaderMap, HeaderName, HeaderValue};
use hyper::body::Bytes;
use pretty_assertions::assert_eq;
use reqwest::Request;
Expand Down Expand Up @@ -352,7 +352,7 @@ mod test {
context.with(|ctx| {
let js_response = WorkerResponse::try_from(Response {
status: reqwest::StatusCode::OK,
headers: headers::HeaderMap::default(),
headers: HeaderMap::default(),
body: Bytes::new(),
})
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/cli/javascript/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;
use std::sync::Arc;

use headers::{HeaderName, HeaderValue};
use http::header::{HeaderName, HeaderValue};

pub mod codec;

Expand Down
8 changes: 4 additions & 4 deletions src/core/async_graphql_hyper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use std::hash::{Hash, Hasher};
use anyhow::Result;
use async_graphql::parser::types::{ExecutableDocument, OperationType};
use async_graphql::{BatchResponse, Executor, Value};
use headers::{HeaderMap, HeaderValue};
use hyper::header::{CACHE_CONTROL, CONTENT_TYPE};
use hyper::{Body, Response, StatusCode};
use http::header::{HeaderMap, HeaderValue, CACHE_CONTROL, CONTENT_TYPE};
use http::{Response, StatusCode};
use hyper::Body;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use tailcall_hasher::TailcallHasher;
Expand Down Expand Up @@ -270,7 +270,7 @@ impl GraphQLResponse {
#[cfg(test)]
mod tests {
use async_graphql::{Name, Response, ServerError, Value};
use hyper::StatusCode;
use http::StatusCode;
use indexmap::IndexMap;
use serde_json::json;

Expand Down
2 changes: 1 addition & 1 deletion src/core/auth/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl BasicVerifier {

#[cfg(test)]
pub mod tests {
use headers::HeaderValue;
use http::header::HeaderValue;

use super::*;

Expand Down
10 changes: 5 additions & 5 deletions src/core/blueprint/cors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use derive_setters::Setters;
use headers::{HeaderName, HeaderValue};
use hyper::header;
use hyper::http::request::Parts;
use http::header;
use http::header::{HeaderName, HeaderValue};
use http::request::Parts;

use crate::core::config;
use crate::core::valid::ValidationError;
Expand Down Expand Up @@ -205,7 +205,7 @@ pub fn is_wildcard(header_value: &HeaderValue) -> bool {

#[cfg(test)]
mod tests {
use headers::HeaderValue;
use http::header::HeaderValue;

use super::*;

Expand All @@ -219,7 +219,7 @@ mod tests {
assert_eq!(
cors.allow_origin_to_header(origin.as_ref()),
Some((
hyper::header::ACCESS_CONTROL_ALLOW_ORIGIN,
header::ACCESS_CONTROL_ALLOW_ORIGIN,
HeaderValue::from_static("https://example.com")
))
);
Expand Down
2 changes: 1 addition & 1 deletion src/core/blueprint/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::Arc;
use std::time::Duration;

use derive_setters::Setters;
use headers::{HeaderMap, HeaderName, HeaderValue};
use http::header::{HeaderMap, HeaderName, HeaderValue};
use rustls_pki_types::{CertificateDer, PrivateKeyDer};

use super::Auth;
Expand Down
2 changes: 1 addition & 1 deletion src/core/blueprint/telemetry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::str::FromStr;

use headers::{HeaderMap, HeaderName, HeaderValue};
use http::header::{HeaderMap, HeaderName, HeaderValue};
use url::Url;

use super::TryFoldConfig;
Expand Down
2 changes: 1 addition & 1 deletion src/core/blueprint/upstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl TryFrom<&ConfigModule> for Upstream {

if config_module.extensions().has_auth() {
// force add auth specific headers to use it to make actual validation
allowed_headers.insert(hyper::header::AUTHORIZATION.to_string());
allowed_headers.insert(http::header::AUTHORIZATION.to_string());
}

get_batch(&config_upstream)
Expand Down
2 changes: 1 addition & 1 deletion src/core/config/cors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use hyper::header;
use http::header;
use serde::{Deserialize, Serialize};

use crate::core::http::Method;
Expand Down
2 changes: 1 addition & 1 deletion src/core/config/reader_context.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::borrow::Cow;
use std::collections::BTreeMap;

use headers::HeaderMap;
use http::header::HeaderMap;

use crate::core::has_headers::HasHeaders;
use crate::core::path::PathString;
Expand Down
2 changes: 1 addition & 1 deletion src/core/endpoint.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use derive_setters::Setters;
use headers::HeaderMap;
use http::header::HeaderMap;

use crate::core::config::Encoding;
use crate::core::http::Method;
Expand Down
4 changes: 2 additions & 2 deletions src/core/graphql/request_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::borrow::Cow;
use std::hash::{Hash, Hasher};

use derive_setters::Setters;
use headers::{HeaderMap, HeaderValue};
use http::header::{HeaderMap, HeaderValue};
use tailcall_hasher::TailcallHasher;

use crate::core::config::{GraphQLOperationType, KeyValue};
Expand Down Expand Up @@ -167,7 +167,7 @@ mod tests {
use std::collections::HashSet;

use async_graphql::Value;
use headers::HeaderMap;
use http::header::HeaderMap;
use pretty_assertions::assert_eq;
use serde_json::json;

Expand Down
2 changes: 1 addition & 1 deletion src/core/grpc/data_loader_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl DataLoaderRequest {
mod tests {
use std::collections::BTreeSet;

use headers::{HeaderMap, HeaderName, HeaderValue};
use http::header::{HeaderMap, HeaderName, HeaderValue};
use pretty_assertions::assert_eq;
use tailcall_fixtures::protobuf;
use url::Url;
Expand Down
7 changes: 4 additions & 3 deletions src/core/grpc/request.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{bail, Result};
use hyper::{HeaderMap, Method};
use http::{HeaderMap, Method};
use reqwest::Request;
use url::Url;

Expand Down Expand Up @@ -45,9 +45,10 @@ mod tests {

use anyhow::Result;
use async_trait::async_trait;
use headers::HeaderMap;
use http::header::HeaderMap;
use http::{Method, StatusCode};
use hyper::body::Bytes;
use reqwest::{Method, Request, StatusCode};
use reqwest::Request;
use serde_json::json;
use tailcall_fixtures::protobuf;
use tonic::{Code, Status};
Expand Down
7 changes: 3 additions & 4 deletions src/core/grpc/request_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use std::hash::{Hash, Hasher};

use anyhow::Result;
use derive_setters::Setters;
use headers::{HeaderMap, HeaderValue};
use hyper::header::CONTENT_TYPE;
use http::header::{HeaderMap, HeaderValue, CONTENT_TYPE};
use tailcall_hasher::TailcallHasher;
use url::Url;

Expand Down Expand Up @@ -133,8 +132,8 @@ mod tests {
use std::collections::HashSet;

use derive_setters::Setters;
use headers::{HeaderMap, HeaderName, HeaderValue};
use hyper::Method;
use http::header::{HeaderMap, HeaderName, HeaderValue};
use http::Method;
use pretty_assertions::assert_eq;
use tailcall_fixtures::protobuf;

Expand Down
2 changes: 1 addition & 1 deletion src/core/has_headers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use headers::HeaderMap;
use http::header::HeaderMap;

use crate::core::ir::{EvalContext, ResolverContextLike};

Expand Down
4 changes: 2 additions & 2 deletions src/core/helpers/headers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use headers::HeaderName;
use http::header::HeaderName;

use crate::core::config::KeyValue;
use crate::core::mustache::Mustache;
Expand All @@ -24,7 +24,7 @@ pub fn to_mustache_headers(headers: &[KeyValue]) -> Valid<MustacheHeaders, Strin
#[cfg(test)]
mod tests {
use anyhow::Result;
use headers::HeaderName;
use http::header::HeaderName;

use super::to_mustache_headers;
use crate::core::config::KeyValue;
Expand Down
4 changes: 2 additions & 2 deletions src/core/http/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cache_control::CacheControl;
use super::Response;

pub fn cache_policy(res: &Response<async_graphql::Value>) -> Option<CacheControl> {
let header = res.headers.get(hyper::header::CACHE_CONTROL)?;
let header = res.headers.get(http::header::CACHE_CONTROL)?;
let value = header.to_str().ok()?;

CacheControl::from_value(value)
Expand All @@ -15,7 +15,7 @@ mod tests {
use std::time::Duration;

use cache_control::Cachability;
use headers::HeaderMap;
use http::header::HeaderMap;

use crate::core::http::Response;

Expand Down
2 changes: 1 addition & 1 deletion src/core/http/data_loader_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Deref for DataLoaderRequest {

#[cfg(test)]
mod tests {
use headers::{HeaderName, HeaderValue};
use http::header::{HeaderName, HeaderValue};

use super::*;
fn create_request_with_headers(url: &str, headers: Vec<(&str, &str)>) -> reqwest::Request {
Expand Down
Loading

0 comments on commit f20bd2f

Please sign in to comment.