From df3485fabffedac6dee44d50f44237e190472575 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Sun, 25 Mar 2018 08:49:59 -0400 Subject: [PATCH] curl: intro `CurlHTTPRequest::unix_socket_path` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/curl/curl.nit | 14 +++++++++++++- lib/curl/native_curl.nit | 9 ++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/curl/curl.nit b/lib/curl/curl.nit index 57a2423..64fbff2 100644 --- a/lib/curl/curl.nit +++ b/lib/curl/curl.nit @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Data transfer with URL syntax +# Data transfer powered by the native curl library # # Download or upload over HTTP with `CurlHTTPRequest` and send emails with `CurlMail`. module curl @@ -116,6 +116,12 @@ class CurlHTTPRequest # Set the user agent for all following HTTP requests var user_agent: nullable String is writable + # Set the Unix domain socket path to use + # + # When not null, enables using a Unix domain socket + # instead of a TCP connection and DNS hostname resolution. + var unix_socket_path: nullable String is writable + # Execute HTTP request # # By default, the response body is returned in an instance of `CurlResponse`. @@ -142,6 +148,12 @@ class CurlHTTPRequest if not err.is_ok then return answer_failure(err.to_i, err.to_s) end + var unix_socket_path = unix_socket_path + if unix_socket_path != null then + err = self.curl.native.easy_setopt(new CURLOption.unix_socket_path, unix_socket_path) + if not err.is_ok then return answer_failure(err.to_i, err.to_s) + end + # Callbacks err = self.curl.native.register_callback_header(callback_receiver) if not err.is_ok then return answer_failure(err.to_i, err.to_s) diff --git a/lib/curl/native_curl.nit b/lib/curl/native_curl.nit index 4b769c1..d3ed43a 100644 --- a/lib/curl/native_curl.nit +++ b/lib/curl/native_curl.nit @@ -752,6 +752,10 @@ extern class CURLOption `{ CURLoption `} # new `{ return CURLOPT_SSH_KEYFUNCTION; `} # new `{ return CURLOPT_SSH_KEYDATA; `} + # TELNET Options + +# new `{ return CURLOPT_TELNETOPTIONS; `} + # Other Options # new `{ return CURLOPT_PRIVATE; `} @@ -759,7 +763,6 @@ extern class CURLOption `{ CURLoption `} # new `{ return CURLOPT_NEW_FILE_PERMS; `} # new `{ return CURLOPT_NEW_DIRECTORY_PERMS; `} - # TELNET Options - -# new `{ return CURLOPT_TELNETOPTIONS; `} + # Set the Unix domain socket + new unix_socket_path `{ return CURLOPT_UNIX_SOCKET_PATH; `} end -- 1.7.9.5