* libs/httpd: Added Cache-Control header to LuCI
[project/luci.git] / libs / httpd / luasrc / httpd / server.lua
index 57221647fceba2893a98e255a601a00f4c0f81d3..7bfac68629bbe0ac7a4e69c695ad68bed6d9b6bd 100644 (file)
@@ -2,6 +2,7 @@
 
 HTTP server implementation for LuCI - helper class
 (c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
+(c) 2008 Steven Barth <steven@midlink.org>
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
@@ -19,6 +20,7 @@ require("socket.http")
 require("luci.util")
 
 READ_BUFSIZE = 1024
+VERSION = 0.2
 
 
 VHost = luci.util.class()
@@ -105,11 +107,15 @@ function Server.error_overload(self, socket)
 end
 
 
-function Server.process( self, thread )
+function Server.process( self, client )
 
        -- Setup sockets and sources
-       local client = thread.socket
+       local thread = {
+               receive = function(self, ...) return luci.httpd.corecv(client, ...) end
+       }
+       
        client:settimeout( 0 )
+       
        local sourcein  = ltn12.source.empty()
        local sourcehdr = luci.http.protocol.header_source( thread )
        local sinkerr   = ltn12.sink.file( io.stderr )
@@ -207,6 +213,8 @@ function Server.process( self, thread )
                        tostring(response.status) .. " " ..
                        luci.http.protocol.statusmsg[response.status] .. "\r\n"
 
+               header = header .. "Server: LuCI HTTPd/" .. tostring(VERSION) .. "\r\n"
+
                
                for k,v in pairs(response.headers) do
                        header = header .. k .. ": " .. v .. "\r\n"