webmcp

diff framework/env/request/process.lua @ 223:32ec28229bb5

Finished removing all references to cgi module (except demo-app); Removed partial loading mechanism
author jbe
date Fri Feb 27 21:49:00 2015 +0100 (2015-02-27)
parents 38e5399718ca
children d5cba50e16ae
line diff
     1.1 --- a/framework/env/request/process.lua	Fri Feb 27 17:18:08 2015 +0100
     1.2 +++ b/framework/env/request/process.lua	Fri Feb 27 21:49:00 2015 +0100
     1.3 @@ -66,7 +66,7 @@
     1.4              assert(routing_view,   "Routing information has no view.")
     1.5              if routing_mode == "redirect" then
     1.6                local routing_params = {}
     1.7 -              for key, value in request.get_param_strings{method="POST", include_internal=true} do
     1.8 +              for key, value in request.get_param_strings{ method="POST", include_internal=true } do
     1.9                  local status, stripped_key = string.match(
    1.10                    key, "^_webmcp_routing%.([^%.]*)%.params%.(.*)$"
    1.11                  )
    1.12 @@ -140,8 +140,8 @@
    1.13  
    1.14    if not success then trace.error{} end
    1.15  
    1.16 -  -- laufzeitermittlung
    1.17 -  trace.exectime{ real = extos.monotonic_hires_time(), cpu = os.clock() }
    1.18 +  -- TODO: extend trace system to generally monitor execution time
    1.19 +  -- trace.exectime{ real = extos.monotonic_hires_time(), cpu = os.clock() }
    1.20  
    1.21    slot.select('trace', trace.render)  -- render trace information
    1.22  
    1.23 @@ -151,8 +151,8 @@
    1.24    if not success then
    1.25      local errobj     = error_info.errobj
    1.26      local stacktrace = error_info.stacktrace
    1.27 -    if not request.get_status() and not request.get_json_request_slots() then
    1.28 -      request.set_status("500 Internal Server Error")
    1.29 +    if not request._status then
    1.30 +      request._status = "500 Internal Server Error"
    1.31      end
    1.32      slot.set_layout('system_error')
    1.33      slot.select('system_error', function()
    1.34 @@ -180,11 +180,9 @@
    1.35      if slot_dump ~= "" then
    1.36        redirect_params.tempstore = tempstore.save(slot_dump)
    1.37      end
    1.38 -    local json_request_slots = request.get_json_request_slots()
    1.39 -    if json_request_slots then
    1.40 -      redirect_params["_webmcp_json_slots[]"] = json_request_slots  
    1.41 -    end
    1.42 -    cgi.redirect(
    1.43 +    request._http_request:send_status("303 See Other")
    1.44 +    request._http_request:send_header(
    1.45 +      "Location",
    1.46        encode.url{
    1.47          base   = request.get_absolute_baseurl(),
    1.48          module = redirect_data.module,
    1.49 @@ -194,28 +192,18 @@
    1.50          anchor = redirect_data.anchor
    1.51        }
    1.52      )
    1.53 -    cgi.send_data()
    1.54 +    request._http_request:finish()
    1.55    end
    1.56  
    1.57    if not success or not redirect_data then
    1.58  
    1.59 -    local http_status = request.get_status()
    1.60 -    if http_status then
    1.61 -      cgi.set_status(http_status)
    1.62 +    request._http_request:send_status(request._status or "200 OK")
    1.63 +    for i, header in ipairs(request._response_headers) do
    1.64 +      request._http_request:send_header(header[1], header[2])
    1.65      end
    1.66 -
    1.67 -    local json_request_slots = request.get_json_request_slots()
    1.68 -    if json_request_slots then
    1.69 -      cgi.set_content_type('application/json')
    1.70 -      local data = {}
    1.71 -      for idx, slot_ident in ipairs(json_request_slots) do
    1.72 -        data[slot_ident] = slot.get_content(slot_ident)
    1.73 -      end
    1.74 -      cgi.send_data(encode.json(data))
    1.75 -    else
    1.76 -      cgi.set_content_type(slot.get_content_type())
    1.77 -      cgi.send_data(slot.render_layout())
    1.78 -    end
    1.79 +    request._http_request:send_header("Content-Type", slot.get_content_type())
    1.80 +    request._http_request:send_data(slot.render_layout())
    1.81 +    request._http_request:finish()
    1.82    end
    1.83  
    1.84  end

Impressum / About Us