refactor: rename feature to http-interop
This commit is contained in:
committed by
Martin Algesten
parent
dff55fda4e
commit
7dcd60cbaf
@@ -24,7 +24,7 @@ cookies = ["cookie", "cookie_store"]
|
|||||||
socks-proxy = ["socks"]
|
socks-proxy = ["socks"]
|
||||||
gzip = ["flate2"]
|
gzip = ["flate2"]
|
||||||
brotli = ["brotli-decompressor"]
|
brotli = ["brotli-decompressor"]
|
||||||
http = ["dep:http"]
|
http-interop = ["dep:http"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
base64 = "0.21"
|
base64 = "0.21"
|
||||||
|
|||||||
@@ -500,7 +500,7 @@ impl Request {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "http")]
|
#[cfg(feature = "http-interop")]
|
||||||
impl From<http::request::Builder> for Request {
|
impl From<http::request::Builder> for Request {
|
||||||
fn from(value: http::request::Builder) -> Self {
|
fn from(value: http::request::Builder) -> Self {
|
||||||
let mut new_request = crate::agent().request(
|
let mut new_request = crate::agent().request(
|
||||||
@@ -529,7 +529,7 @@ impl From<http::request::Builder> for Request {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "http")]
|
#[cfg(feature = "http-interop")]
|
||||||
impl From<Request> for http::request::Builder {
|
impl From<Request> for http::request::Builder {
|
||||||
fn from(value: Request) -> Self {
|
fn from(value: Request) -> Self {
|
||||||
value
|
value
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ use flate2::read::MultiGzDecoder;
|
|||||||
#[cfg(feature = "brotli")]
|
#[cfg(feature = "brotli")]
|
||||||
use brotli_decompressor::Decompressor as BrotliDecoder;
|
use brotli_decompressor::Decompressor as BrotliDecoder;
|
||||||
|
|
||||||
#[cfg(feature = "http")]
|
#[cfg(feature = "http-interop")]
|
||||||
use std::net::{IpAddr, Ipv4Addr};
|
use std::net::{IpAddr, Ipv4Addr};
|
||||||
|
|
||||||
pub const DEFAULT_CONTENT_TYPE: &str = "text/plain";
|
pub const DEFAULT_CONTENT_TYPE: &str = "text/plain";
|
||||||
@@ -875,7 +875,7 @@ impl Read for ErrorReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "http")]
|
#[cfg(feature = "http-interop")]
|
||||||
impl<T: AsRef<[u8]> + Send + Sync + 'static> From<http::Response<T>> for Response {
|
impl<T: AsRef<[u8]> + Send + Sync + 'static> From<http::Response<T>> for Response {
|
||||||
fn from(value: http::Response<T>) -> Self {
|
fn from(value: http::Response<T>) -> Self {
|
||||||
let version_str = format!("{:?}", value.version());
|
let version_str = format!("{:?}", value.version());
|
||||||
@@ -907,7 +907,7 @@ impl<T: AsRef<[u8]> + Send + Sync + 'static> From<http::Response<T>> for Respons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "http")]
|
#[cfg(feature = "http-interop")]
|
||||||
fn create_builder(response: &Response) -> http::response::Builder {
|
fn create_builder(response: &Response) -> http::response::Builder {
|
||||||
let http_version = match response.http_version() {
|
let http_version = match response.http_version() {
|
||||||
"HTTP/0.9" => http::Version::HTTP_09,
|
"HTTP/0.9" => http::Version::HTTP_09,
|
||||||
@@ -935,14 +935,14 @@ fn create_builder(response: &Response) -> http::response::Builder {
|
|||||||
response_builder
|
response_builder
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "http")]
|
#[cfg(feature = "http-interop")]
|
||||||
impl From<Response> for http::Response<Box<dyn Read + Send + Sync + 'static>> {
|
impl From<Response> for http::Response<Box<dyn Read + Send + Sync + 'static>> {
|
||||||
fn from(value: Response) -> Self {
|
fn from(value: Response) -> Self {
|
||||||
create_builder(&value).body(value.into_reader()).unwrap()
|
create_builder(&value).body(value.into_reader()).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "http")]
|
#[cfg(feature = "http-interop")]
|
||||||
impl From<Response> for http::Response<String> {
|
impl From<Response> for http::Response<String> {
|
||||||
fn from(value: Response) -> Self {
|
fn from(value: Response) -> Self {
|
||||||
create_builder(&value)
|
create_builder(&value)
|
||||||
@@ -1291,7 +1291,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "http")]
|
#[cfg(feature = "http-interop")]
|
||||||
fn convert_http_response() {
|
fn convert_http_response() {
|
||||||
use http::{Response, StatusCode, Version};
|
use http::{Response, StatusCode, Version};
|
||||||
|
|
||||||
@@ -1319,7 +1319,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "http")]
|
#[cfg(feature = "http-interop")]
|
||||||
fn convert_http_response_string() {
|
fn convert_http_response_string() {
|
||||||
use http::{Response, StatusCode, Version};
|
use http::{Response, StatusCode, Version};
|
||||||
|
|
||||||
@@ -1337,7 +1337,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "http")]
|
#[cfg(feature = "http-interop")]
|
||||||
fn convert_http_response_bad_header() {
|
fn convert_http_response_bad_header() {
|
||||||
use http::{Response, StatusCode, Version};
|
use http::{Response, StatusCode, Version};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user