lib/curl: fix indentation
authorAlexis Laferrière <alexis.laf@xymus.net>
Thu, 6 Mar 2014 18:27:36 +0000 (13:27 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Thu, 6 Mar 2014 18:27:36 +0000 (13:27 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/curl/curl.nit

index b00bb70..856c5bd 100644 (file)
@@ -47,15 +47,15 @@ class Curl
                return new CurlHTTPRequest(url, self)
        end
 
-  # Get a MAIL Request Object
-  fun mail_request: nullable CurlMailRequest
-  do
-    var err: CURLCode
-    err = self.prim_curl.easy_setopt(new CURLOption.follow_location, 1)
-    if not err.is_ok then return null
+       # Get a MAIL Request Object
+       fun mail_request: nullable CurlMailRequest
+       do
+               var err: CURLCode
+               err = self.prim_curl.easy_setopt(new CURLOption.follow_location, 1)
+               if not err.is_ok then return null
 
-    return new CurlMailRequest(self)
-  end
+               return new CurlMailRequest(self)
+       end
 
        # Release Curl instance
        fun destroy do self.prim_curl.easy_clean
@@ -96,18 +96,18 @@ end
 # CURL HTTP Request
 class CurlHTTPRequest
        super CurlRequest
-  super CCurlCallbacks
-  super CurlCallbacksRegisterIntern
+       super CCurlCallbacks
+       super CurlCallbacksRegisterIntern
 
-  var url: String
+       var url: String
        var datas: nullable HeaderMap writable = null
        var headers: nullable HeaderMap writable = null
 
-  init (url: String, curl: nullable Curl)
-  do
-    self.url = url
-    self.curl = curl
-  end
+       init (url: String, curl: nullable Curl)
+       do
+               self.url = url
+               self.curl = curl
+       end
 
        # Execute HTTP request with settings configured through attribute
        redef fun execute: CurlResponse
@@ -120,21 +120,21 @@ class CurlHTTPRequest
                if self.delegate != null then callback_receiver = self.delegate.as(not null)
 
                var err: CURLCode
-    # Callbacks
+               # Callbacks
                err = self.curl.prim_curl.register_callback(callback_receiver, new CURLCallbackType.header)
                if not err.is_ok then return answer_failure(err.to_i, err.to_s)
 
                err = self.curl.prim_curl.register_callback(callback_receiver, new CURLCallbackType.body)
                if not err.is_ok then return answer_failure(err.to_i, err.to_s)
 
-    # HTTP Header
+               # HTTP Header
                if self.headers != null then
                        var headers_joined = self.headers.join_pairs(": ")
                        err = self.curl.prim_curl.easy_setopt(new CURLOption.httpheader, headers_joined.to_curlslist)
                        if not err.is_ok then return answer_failure(err.to_i, err.to_s)
                end
 
-    # Datas
+               # Datas
                if self.datas != null then
                        var postdatas = self.datas.to_url_encoded(self.curl.prim_curl)
                        err = self.curl.prim_curl.easy_setopt(new CURLOption.postfields, postdatas)
@@ -203,10 +203,10 @@ end
 
 # CURL Mail Request
 class CurlMailRequest
-  super CurlRequest
-  super CCurlCallbacks
+       super CurlRequest
+       super CCurlCallbacks
 
-  var headers: nullable HeaderMap writable = null
+       var headers: nullable HeaderMap writable = null
        var headers_body: nullable HeaderMap writable = null
        var from: nullable String writable = null
        var to: nullable Array[String] writable = null
@@ -216,11 +216,11 @@ class CurlMailRequest
        var body: nullable String writable = ""
        private var supported_outgoing_protocol: Array[String]
 
-  init (curl: nullable Curl)
-  do
-    self.curl = curl
+       init (curl: nullable Curl)
+       do
+               self.curl = curl
                self.supported_outgoing_protocol = once ["smtp", "smtps"]
-  end
+       end
 
        # Helper method to add conventional space while building entire mail
        private fun add_conventional_space(str: String):String do return "{str}\n" end
@@ -232,12 +232,12 @@ class CurlMailRequest
                return "{str}{att}\n"
        end
 
-  # Helper method to add entire list of pairs to mail content
-  private fun add_pairs_to_content(content: String, pairs: HeaderMap):String
-  do
-    for h_key, h_val in pairs do content = add_pair_to_content(content, h_key, h_val)
-    return content
-  end
+       # Helper method to add entire list of pairs to mail content
+       private fun add_pairs_to_content(content: String, pairs: HeaderMap):String
+       do
+               for h_key, h_val in pairs do content = add_pair_to_content(content, h_key, h_val)
+               return content
+       end
 
        # Check for host and protocol availability
        private fun is_supported_outgoing_protocol(host: String):CURLCode
@@ -255,7 +255,7 @@ class CurlMailRequest
 
                var err: CURLCode
 
-    # Host & Protocol
+               # Host & Protocol
                err = is_supported_outgoing_protocol(host)
                if not err.is_ok then return answer_failure(err.to_i, err.to_s)
                err = self.curl.prim_curl.easy_setopt(new CURLOption.url, host)
@@ -279,10 +279,10 @@ class CurlMailRequest
 
                var success_response: CurlMailResponseSuccess = new CurlMailResponseSuccess
                var err: CURLCode
-    var content = ""
-    # Headers
+               var content = ""
+               # Headers
                if self.headers != null then
-      content = add_pairs_to_content(content, self.headers.as(not null))
+                       content = add_pairs_to_content(content, self.headers.as(not null))
                end
 
                # Recipients
@@ -301,7 +301,7 @@ class CurlMailRequest
                err = self.curl.prim_curl.easy_setopt(new CURLOption.mail_rcpt, g_rec.to_curlslist)
                if not err.is_ok then return answer_failure(err.to_i, err.to_s)
 
-    # From
+               # From
                if not self.from == null then
                        content = add_pair_to_content(content, "From:", self.from)
                        err = self.curl.prim_curl.easy_setopt(new CURLOption.mail_from, self.from.as(not null))
@@ -311,9 +311,9 @@ class CurlMailRequest
                # Subject
                content = add_pair_to_content(content, "Subject:", self.subject)
 
-    # Headers body
+               # Headers body
                if self.headers_body != null then
-      content = add_pairs_to_content(content, self.headers_body.as(not null))
+                       content = add_pairs_to_content(content, self.headers_body.as(not null))
                end
 
                # Body
@@ -339,7 +339,7 @@ end
 
 # Callbacks attributes
 abstract class CurlCallbacksRegisterIntern
-  var delegate: nullable CurlCallbacks writable = null
+       var delegate: nullable CurlCallbacks writable = null
 end
 
 # Abstract Curl request response
@@ -394,7 +394,7 @@ end
 
 # Success Response Class of mail request
 class CurlMailResponseSuccess
-  super CurlResponseSuccessIntern
+       super CurlResponseSuccessIntern
 end
 
 # Success Response Class of a downloaded File