libs: remove obsolete iwinfo, its independant now
[project/luci.git] / libs / http / luasrc / http / protocol.lua
index ab696d5..d8ef09f 100644 (file)
@@ -248,7 +248,7 @@ process_states['headers'] = function( msg, chunk )
        if chunk ~= nil then
 
                -- Look for a valid header format
-               local hdr, val = chunk:match( "^([A-Z][A-Za-z0-9%-_]+): +(.+)$" )
+               local hdr, val = chunk:match( "^([A-Za-z][A-Za-z0-9%-_]+): +(.+)$" )
 
                if type(hdr) == "string" and hdr:len() > 0 and
                   type(val) == "string" and val:len() > 0
@@ -563,12 +563,14 @@ function parse_message_header( src )
                        -- Populate common environment variables
                        msg.env = {
                                CONTENT_LENGTH    = msg.headers['Content-Length'];
-                               CONTENT_TYPE      = msg.headers['Content-Type'];
+                               CONTENT_TYPE      = msg.headers['Content-Type'] or msg.headers['Content-type'];
                                REQUEST_METHOD    = msg.request_method:upper();
                                REQUEST_URI       = msg.request_uri;
                                SCRIPT_NAME       = msg.request_uri:gsub("?.+$","");
                                SCRIPT_FILENAME   = "";         -- XXX implement me
-                               SERVER_PROTOCOL   = "HTTP/" .. string.format("%.1f", msg.http_version)
+                               SERVER_PROTOCOL   = "HTTP/" .. string.format("%.1f", msg.http_version);
+                               QUERY_STRING      = msg.request_uri:match("?")
+                                       and msg.request_uri:gsub("^.+?","") or ""
                        }
 
                        -- Populate HTTP_* environment variables
@@ -617,7 +619,7 @@ function parse_message_body( src, msg, filecb )
 
        -- Is it application/x-www-form-urlencoded ?
        elseif msg.env.REQUEST_METHOD == "POST" and msg.env.CONTENT_TYPE and
-              msg.env.CONTENT_TYPE == "application/x-www-form-urlencoded"
+              msg.env.CONTENT_TYPE:match("^application/x%-www%-form%-urlencoded")
        then
                return urldecode_message_body( src, msg, filecb )
 
@@ -671,6 +673,7 @@ end
 -- @class table
 statusmsg = {
        [200] = "OK",
+       [206] = "Partial Content",
        [301] = "Moved Permanently",
        [302] = "Found",
        [304] = "Not Modified",
@@ -678,8 +681,10 @@ statusmsg = {
        [403] = "Forbidden",
        [404] = "Not Found",
        [405] = "Method Not Allowed",
+       [408] = "Request Time-out",
        [411] = "Length Required",
        [412] = "Precondition Failed",
+       [416] = "Requested range not satisfiable",
        [500] = "Internal Server Error",
        [503] = "Server Unavailable",
 }