Skip to content

Commit

Permalink
fix: breaking API in surf 2.0.0-alpha5
Browse files Browse the repository at this point in the history
  • Loading branch information
fMeow committed Sep 15, 2020
1 parent cff0653 commit 349cd16
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ status = "actively-developed"
[features]
default = [ "rocksdb", "reqwest_async" ]
blocking = [ "maybe-async/is_sync" ]
reqwest_async = [ "reqwest" ]
reqwest_async = [ "reqwest"]
reqwest_blocking = [ "reqwest/blocking", "blocking" ]
surf_async = [ "surf" ]
surf_async = [ "surf", "http-types" ]
cluster = [ ]
enterprise = [ ]
mmfiles = [ ]
Expand Down Expand Up @@ -52,7 +52,11 @@ url = "2"
optional = true

[dependencies.surf]
version = "2.0.0-alpha.4"
version = "2.0.0-alpha.5"
optional = true

[dependencies.http-types]
version = "2.0.0"
optional = true

[dev-dependencies]
Expand Down
18 changes: 9 additions & 9 deletions src/client/surf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl ClientExt for SurfClient {
&self,
request: http::Request<String>,
) -> Result<http::Response<String>, ClientError> {
use ::surf::http_types::headers::HeaderName as SurfHeaderName;
use http_types::headers::HeaderName as SurfHeaderName;

let method = request.method().clone();
let url = request.uri().to_owned().to_string();
Expand All @@ -50,20 +50,20 @@ impl ClientExt for SurfClient {
};

let req = self.headers.iter().fold(req, |req, (k, v)| {
req.set_header(
req.header(
SurfHeaderName::from_str(k.as_str()).unwrap(),
v.to_str().unwrap(),
)
});
let req = request.headers().iter().fold(req, |req, (k, v)| {
req.set_header(
req.header(
SurfHeaderName::from_str(k.as_str()).unwrap(),
v.to_str().unwrap(),
)
});

let mut resp = req
.body_string(text.to_owned())
.body(text.to_owned())
.await
.map_err(|e| ClientError::HttpClient(format!("{:?}", e)))?;

Expand Down Expand Up @@ -95,11 +95,11 @@ impl ClientExt for SurfClient {
}

let http_version = version.map(|v| match v {
::surf::http_types::Version::Http0_9 => Version::HTTP_09,
::surf::http_types::Version::Http1_0 => Version::HTTP_10,
::surf::http_types::Version::Http1_1 => Version::HTTP_11,
::surf::http_types::Version::Http2_0 => Version::HTTP_2,
::surf::http_types::Version::Http3_0 => Version::HTTP_3,
http_types::Version::Http0_9 => Version::HTTP_09,
http_types::Version::Http1_0 => Version::HTTP_10,
http_types::Version::Http1_1 => Version::HTTP_11,
http_types::Version::Http2_0 => Version::HTTP_2,
http_types::Version::Http3_0 => Version::HTTP_3,
_ => unreachable!(),
});

Expand Down

0 comments on commit 349cd16

Please sign in to comment.