curl: intro `CurlHTTPRequest::unix_socket_path`
authorAlexis Laferrière <alexis.laf@xymus.net>
Sun, 25 Mar 2018 12:49:59 +0000 (08:49 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Sun, 25 Mar 2018 15:55:22 +0000 (11:55 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/curl/curl.nit
lib/curl/native_curl.nit

index 57a2423..64fbff2 100644 (file)
@@ -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)
index 4b769c1..d3ed43a 100644 (file)
@@ -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