From fa12fd3c82a50e33e49f68e1cf8ae4d444b8d035 Mon Sep 17 00:00:00 2001 From: Deepak Lewis <192128+tailrecur@users.noreply.github.com> Date: Fri, 19 Feb 2021 14:58:35 +0100 Subject: [PATCH] Disable expect header usage using a request extension --- src/client.rs | 5 +++++ src/config/mod.rs | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/client.rs b/src/client.rs index 704f97cf..fa2d7f3e 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1174,6 +1174,11 @@ impl HttpClient { headers.append(&header_to_curl_string(name, value, title_case))?; } + request + .extensions() + .get::() + .map(|_| headers.append("Expect:")); + easy.http_headers(headers)?; Ok((easy, future)) diff --git a/src/config/mod.rs b/src/config/mod.rs index 1364356c..69efead2 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -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 @@ -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);