From 16133f713af1e5493a5141b87edb939343d7ee73 Mon Sep 17 00:00:00 2001 From: Joseph Angelo Date: Thu, 5 May 2022 07:31:06 -0700 Subject: [PATCH] Expose the CURLOPT_HTTP09_ALLOWED libcurl option (#447) --- curl-sys/lib.rs | 2 ++ src/easy/handle.rs | 5 +++++ src/easy/handler.rs | 11 +++++++++++ systest/build.rs | 1 + 4 files changed, 19 insertions(+) diff --git a/curl-sys/lib.rs b/curl-sys/lib.rs index 5bd87f0a8..9a55624c9 100644 --- a/curl-sys/lib.rs +++ b/curl-sys/lib.rs @@ -598,6 +598,8 @@ pub const CURLOPT_PROXY_SSLKEY: CURLoption = CURLOPTTYPE_OBJECTPOINT + 256; pub const CURLOPT_DOH_URL: CURLoption = CURLOPTTYPE_OBJECTPOINT + 279; pub const CURLOPT_UPLOAD_BUFFERSIZE: CURLoption = CURLOPTTYPE_LONG + 280; +pub const CURLOPT_HTTP09_ALLOWED: CURLoption = CURLOPTTYPE_LONG + 285; + pub const CURLOPT_MAXAGE_CONN: CURLoption = CURLOPTTYPE_LONG + 288; pub const CURLOPT_SSLCERT_BLOB: CURLoption = CURLOPTTYPE_BLOB + 291; diff --git a/src/easy/handle.rs b/src/easy/handle.rs index 597a1af02..b109adc96 100644 --- a/src/easy/handle.rs +++ b/src/easy/handle.rs @@ -1280,6 +1280,11 @@ impl Easy { self.inner.pipewait(wait) } + /// Same as [`Easy2::http_09_allowed`](struct.Easy2.html#method.http_09_allowed) + pub fn http_09_allowed(&mut self, allow: bool) -> Result<(), Error> { + self.inner.http_09_allowed(allow) + } + // ========================================================================= // Other methods diff --git a/src/easy/handler.rs b/src/easy/handler.rs index cfb0f9f85..5ace28bab 100644 --- a/src/easy/handler.rs +++ b/src/easy/handler.rs @@ -2944,6 +2944,17 @@ impl Easy2 { self.setopt_long(curl_sys::CURLOPT_PIPEWAIT, wait as c_long) } + /// Allow HTTP/0.9 compliant responses + /// + /// Set allow to `true` to tell libcurl to allow HTTP/0.9 responses. A HTTP/0.9 + /// response is a server response entirely without headers and only a body. + /// + /// By default this option is not set and corresponds to + /// `CURLOPT_HTTP09_ALLOWED`. + pub fn http_09_allowed(&mut self, allow: bool) -> Result<(), Error> { + self.setopt_long(curl_sys::CURLOPT_HTTP09_ALLOWED, allow as c_long) + } + // ========================================================================= // Other methods diff --git a/systest/build.rs b/systest/build.rs index 4d5b2e8c6..576e3e51f 100644 --- a/systest/build.rs +++ b/systest/build.rs @@ -141,6 +141,7 @@ fn main() { "CURLE_SSL_INVALIDCERTSTATUS" => return true, "CURLE_HTTP2_STREAM" => return true, "CURLE_RECURSIVE_API_CALL" => return true, + "CURLOPT_HTTP09_ALLOWED" => return true, _ => {} } }