Skip to content

Commit

Permalink
Disable expect header usage using a request extension
Browse files Browse the repository at this point in the history
  • Loading branch information
tailrecur committed Feb 19, 2021
1 parent e0b6fd8 commit fa12fd3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,11 @@ impl HttpClient {
headers.append(&header_to_curl_string(name, value, title_case))?;
}

request
.extensions()
.get::<DisableExpectHeader>()
.map(|_| headers.append("Expect:"));

easy.http_headers(headers)?;

Ok((easy, future))
Expand Down
9 changes: 9 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,11 @@ pub trait Configurable: internal::ConfigurableBase {
self.configure(TitleCaseHeaders(enable))
}

/// Disable using `Expect` header to test request validity
fn disable_expect_header(self) -> Self {
self.configure(DisableExpectHeader(true))
}

/// Enable or disable comprehensive per-request metrics collection.
///
/// When enabled, detailed timing metrics will be tracked while a request is
Expand Down Expand Up @@ -919,3 +924,7 @@ impl SetOpt for IpVersion {
/// Send header names as title case instead of lowercase.
#[derive(Clone, Debug)]
pub(crate) struct TitleCaseHeaders(pub(crate) bool);

/// Disable Expect Header usage
#[derive(Clone, Debug)]
pub(crate) struct DisableExpectHeader(pub(crate) bool);

0 comments on commit fa12fd3

Please sign in to comment.