Merge: share: shallow clone bdwgc for Android and iOS
authorJean Privat <jean@pryen.org>
Thu, 29 Mar 2018 00:11:32 +0000 (20:11 -0400)
committerJean Privat <jean@pryen.org>
Thu, 29 Mar 2018 00:11:32 +0000 (20:11 -0400)
When compiling a Nit app for Android, a specific branch of bdwgc/libgc/boehm-gc is cloned locally. Using a shallow clone only fetches the last commit, for a faster download and to use less disk space.

Closes #2621.

Pull-Request: #2624
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>

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 1f5cd11..d3ed43a 100644 (file)
@@ -89,7 +89,7 @@ extern class NativeCurl `{ CURL * `}
                if obj isa Int then return native_setopt_int(opt, obj)
                if obj == true then return native_setopt_int(opt, 1)
                if obj == false then return native_setopt_int(opt, 0)
-               if obj isa String then return native_setopt_string(opt, obj)
+               if obj isa String then return native_setopt_string(opt, obj.to_cstring)
                if obj isa FileWriter then return native_setopt_file(opt, obj._file.as(not null))
                if obj isa CURLSList then return native_setopt_slist(opt, obj)
                return once new CURLCode.unknown_option
@@ -107,9 +107,8 @@ extern class NativeCurl `{ CURL * `}
        private fun native_setopt_slist(opt: CURLOption, list: CURLSList): CURLCode `{ return curl_easy_setopt( self, opt, list); `}
 
        # Internal method to set options to CURL using String parameter.
-       private fun native_setopt_string(opt: CURLOption, str: String): CURLCode import String.to_cstring `{
-               char *rStr = String_to_cstring(str);
-               return curl_easy_setopt( self, opt, rStr);
+       private fun native_setopt_string(opt: CURLOption, str: CString): CURLCode `{
+               return curl_easy_setopt( self, opt, str);
        `}
 
        # Request Chars internal information from the CURL session
@@ -121,7 +120,7 @@ extern class NativeCurl `{ CURL * `}
                 return answ.item.to_s
        end
 
-       # Internal method used to get String object information initially knowns as C Chars type
+       # Internal method used to get String object information initially known as C Chars type
        private fun native_getinfo_chars(opt: CURLInfoChars, res: Ref[CString]): CURLCode
        import Ref[CString].item= `{
                char *r;
@@ -753,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; `}
@@ -760,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