Merge: lib/nitcorn: fix last warnings
authorJean Privat <jean@pryen.org>
Tue, 7 Jun 2016 16:07:22 +0000 (12:07 -0400)
committerJean Privat <jean@pryen.org>
Tue, 7 Jun 2016 16:07:22 +0000 (12:07 -0400)
Pull-Request: #2147
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/nitcorn/examples/src/htcpcp_server.nit
lib/nitcorn/http_request.nit
lib/nitcorn/http_response.nit
lib/nitcorn/media_types.nit

index 37fa87e..315d76f 100644 (file)
@@ -21,15 +21,19 @@ module htcpcp_server
 
 import nitcorn
 
+# Nitcorn Action used to answer requests.
 class HTCPCPAction
        super Action
+
+       # Brewing status.
        var brewing = false
-  var is_teapot = false
+
+       # Teapot status.
+       var is_teapot = false
 
        redef fun answer(http_request, turi) do
                var message: String
                var method = http_request.method
-               var headers = http_request.header
                var response: HttpResponse
 
                if is_teapot == true then
@@ -77,10 +81,13 @@ class HTCPCPAction
        end
 end
 
-
+# Nitcorn server.
 class HTCPCServer
+
+       # Port to listen to.
        var port: Int
 
+       # Start listening.
        fun run do
                var vh = new VirtualHost("localhost:{port}")
                vh.routes.add new Route("/", new HTCPCPAction)
index 9e94493..1833fca 100644 (file)
@@ -24,7 +24,7 @@ import core
 
 # A request received over HTTP, is build by `HttpRequestParser`
 class HttpRequest
-       private init do end
+       private init is old_style_init do end
 
        # HTTP protocol version
        var http_version: String
@@ -114,6 +114,7 @@ class HttpRequestParser
        # Words of the first line
        private var first_line = new Array[String]
 
+       # Parse the `first_line`, `header_fields` and `body` of `full_request`.
        fun parse_http_request(full_request: String): nullable HttpRequest
        do
                clear_data
index 3d0fd33..08d2968 100644 (file)
@@ -97,7 +97,8 @@ class HttpStatusCodes
        # All know code and their message
        var codes = new HashMap[Int, String]
 
-       protected init do insert_status_codes
+       # Init the status `codes` list.
+       protected init is old_style_init do insert_status_codes
 
        # Get the message associated to the status `code`, return `null` in unknown
        fun [](code: Int): nullable String
index 37dd9db..305f314 100644 (file)
@@ -20,6 +20,8 @@ module media_types
 
 # Map of known MIME types
 class MediaTypes
+
+       # MIME types by extensions.
        protected var types = new HashMap[String, String]
 
        # Get the type/subtype associated to a file extension `ext`
@@ -106,4 +108,5 @@ class MediaTypes
        end
 end
 
+# MIME types list.
 fun media_types: MediaTypes do return once new MediaTypes