projects: update some short descriptions
[nit.git] / lib / curl / curl.nit
index 8c58646..11c39bf 100644 (file)
@@ -77,15 +77,12 @@ class CurlHTTPRequest
        super NativeCurlCallbacks
 
        var url: String
-       var datas: nullable HeaderMap = null is writable
-       var headers: nullable HeaderMap = null is writable
-       var delegate: nullable CurlCallbacks = null is writable
+       var datas: nullable HeaderMap is writable
+       var headers: nullable HeaderMap is writable
+       var delegate: nullable CurlCallbacks is writable
 
        # Set the user agent for all following HTTP requests
-       fun user_agent=(name: String)
-       do
-               curl.native.easy_setopt(new CURLOption.user_agent, name)
-       end
+       var user_agent: nullable String is writable
 
        # Execute HTTP request with settings configured through attribute
        fun execute: CurlResponse
@@ -104,6 +101,12 @@ class CurlHTTPRequest
                err = self.curl.native.easy_setopt(new CURLOption.url, url)
                if not err.is_ok then return answer_failure(err.to_i, err.to_s)
 
+               var user_agent = user_agent
+               if user_agent != null then
+                       err = curl.native.easy_setopt(new CURLOption.user_agent, user_agent)
+                       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)
@@ -131,7 +134,7 @@ class CurlHTTPRequest
                if err_resp != null then return err_resp
 
                var st_code = self.curl.native.easy_getinfo_long(new CURLInfoLong.response_code)
-               if not st_code == null then success_response.status_code = st_code.response
+               if not st_code == null then success_response.status_code = st_code
 
                return success_response
        end
@@ -162,7 +165,7 @@ class CurlHTTPRequest
                if not output_file_name == null then
                        opt_name = output_file_name
                else if not self.url.substring(self.url.length-1, self.url.length) == "/" then
-                       opt_name = self.url.basename("")
+                       opt_name = self.url.basename
                else
                        return answer_failure(0, "Unable to extract file name, please specify one")
                end
@@ -176,16 +179,16 @@ class CurlHTTPRequest
                if err_resp != null then return err_resp
 
                var st_code = self.curl.native.easy_getinfo_long(new CURLInfoLong.response_code)
-               if not st_code == null then success_response.status_code = st_code.response
+               if not st_code == null then success_response.status_code = st_code
 
                var speed = self.curl.native.easy_getinfo_double(new CURLInfoDouble.speed_download)
-               if not speed == null then success_response.speed_download = speed.response
+               if not speed == null then success_response.speed_download = speed
 
                var size = self.curl.native.easy_getinfo_double(new CURLInfoDouble.size_download)
-               if not size == null then success_response.size_download = size.response
+               if not size == null then success_response.size_download = size
 
                var time = self.curl.native.easy_getinfo_double(new CURLInfoDouble.total_time)
-               if not time == null then success_response.total_time = time.response
+               if not time == null then success_response.total_time = time
 
                success_response.file.close
 
@@ -249,7 +252,10 @@ class CurlMail
        # Content header
        var headers_body = new HeaderMap is lazy, writable
 
-       private var supported_outgoing_protocol: Array[String] = ["smtp", "smtps"]
+       # Protocols supported to send mail to a server
+       #
+       # Default value at `["smtp", "smtps"]`
+       var supported_outgoing_protocol: Array[String] = ["smtp", "smtps"]
 
        # Helper method to add pair values to mail content while building it (ex: "To:", "address@mail.com")
        private fun add_pair_to_content(str: String, att: String, val: nullable String): String
@@ -435,9 +441,9 @@ class CurlFileResponseSuccess
        super CurlResponseSuccessIntern
 
        var status_code = 0
-       var speed_download = 0
-       var size_download = 0
-       var total_time = 0
+       var speed_download = 0.0
+       var size_download = 0.0
+       var total_time = 0.0
        private var file: nullable FileWriter = null
 
        # Receive bytes stream from request due to stream callback registering