Alejandro Mery
16 years ago
2 changed files with 138 additions and 0 deletions
@ -0,0 +1,28 @@
|
||||
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
||||
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
||||
#
|
||||
# Filename: package/.../lua-wsapi/nil_body.patch
|
||||
# Copyright (C) 2009 The OpenSDE Project
|
||||
#
|
||||
# More information can be found in the files COPYING and README.
|
||||
#
|
||||
# This patch file is dual-licensed. It is available under the license the
|
||||
# patched project is licensed under, as long as it is an OpenSource license
|
||||
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
|
||||
# of the GNU General Public License as published by the Free Software
|
||||
# Foundation; either version 2 of the License, or (at your option) any later
|
||||
# version.
|
||||
# --- SDE-COPYRIGHT-NOTE-END ---
|
||||
|
||||
--- ./src/wsapi/common.lua.orig 2009-06-02 17:11:08.000000000 +0200
|
||||
+++ ./src/wsapi/common.lua 2009-06-02 17:18:51.000000000 +0200
|
||||
@@ -58,6 +58,9 @@
|
||||
|
||||
function send_content(out, res_iter, write_method)
|
||||
local write = out[write_method or "write"]
|
||||
+ if res_iter == nil then
|
||||
+ return
|
||||
+ end
|
||||
local ok, res = xpcall(res_iter, debug.traceback)
|
||||
while ok and res do
|
||||
write(out, res)
|
@ -0,0 +1,110 @@
|
||||
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
||||
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
||||
#
|
||||
# Filename: package/.../lua-wsapi/status_names.patch
|
||||
# Copyright (C) 2009 The OpenSDE Project
|
||||
#
|
||||
# More information can be found in the files COPYING and README.
|
||||
#
|
||||
# This patch file is dual-licensed. It is available under the license the
|
||||
# patched project is licensed under, as long as it is an OpenSource license
|
||||
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
|
||||
# of the GNU General Public License as published by the Free Software
|
||||
# Foundation; either version 2 of the License, or (at your option) any later
|
||||
# version.
|
||||
# --- SDE-COPYRIGHT-NOTE-END ---
|
||||
|
||||
--- ./src/wsapi/xavante.lua.orig 2009-06-02 16:30:03.000000000 +0200
|
||||
+++ ./src/wsapi/xavante.lua 2009-06-02 17:09:31.000000000 +0200
|
||||
@@ -4,6 +4,7 @@
|
||||
-- Author: Fabio Mascarenhas
|
||||
-- Copyright (c) 2007 Kepler Project
|
||||
--
|
||||
+-- vim: ts=3 cw=3 et:
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
require "coxpcall"
|
||||
@@ -43,6 +44,49 @@
|
||||
end
|
||||
end
|
||||
|
||||
+local status_name = {
|
||||
+ [100] = "Continue",
|
||||
+ [101] = "Switching Protocols",
|
||||
+ [200] = "OK",
|
||||
+ [201] = "Created",
|
||||
+ [202] = "Accepted",
|
||||
+ [203] = "Non-Authoritative Information",
|
||||
+ [204] = "No Content",
|
||||
+ [205] = "Reset Content",
|
||||
+ [206] = "Partial Content",
|
||||
+ [300] = "Multiple Choices",
|
||||
+ [301] = "Moved Permanently",
|
||||
+ [302] = "Found",
|
||||
+ [303] = "See Other",
|
||||
+ [304] = "Not Modified",
|
||||
+ [305] = "Use Proxy",
|
||||
+ [307] = "Temporary Redirect",
|
||||
+ [400] = "Bad Request",
|
||||
+ [401] = "Unauthorized",
|
||||
+ [402] = "Payment Required",
|
||||
+ [403] = "Forbidden",
|
||||
+ [404] = "Not Found",
|
||||
+ [405] = "Method Not Allowed",
|
||||
+ [406] = "Not Acceptable",
|
||||
+ [407] = "Proxy Authentication Required",
|
||||
+ [408] = "Request Time-out",
|
||||
+ [409] = "Conflict",
|
||||
+ [410] = "Gone",
|
||||
+ [411] = "Length Required",
|
||||
+ [412] = "Precondition Failed",
|
||||
+ [413] = "Request Entity Too Large",
|
||||
+ [414] = "Request-URI Too Large",
|
||||
+ [415] = "Unsupported Media Type",
|
||||
+ [416] = "Requested range not satisfiable",
|
||||
+ [417] = "Expectation Failed",
|
||||
+ [500] = "Internal Server Error",
|
||||
+ [501] = "Not Implemented",
|
||||
+ [502] = "Bad Gateway",
|
||||
+ [503] = "Service Unavailable",
|
||||
+ [504] = "Gateway Time-out",
|
||||
+ [505] = "HTTP Version not supported",
|
||||
+}
|
||||
+
|
||||
local function wsapihandler (req, res, wsapi_run, app_prefix, docroot, app_path)
|
||||
local path_info_pat = "^" .. (app_prefix or "") .. "(.*)"
|
||||
set_cgivars(req, docroot, path_info_pat, app_prefix)
|
||||
@@ -57,7 +101,8 @@
|
||||
wsapi_env.APP_PATH = app_path
|
||||
|
||||
local function set_status(status)
|
||||
- res.statusline = "HTTP/1.1 " .. tostring(status)
|
||||
+ res.statusline = string.format("HTTP/1.1 %d %s",
|
||||
+ status, status_name[status] or "Unknown")
|
||||
end
|
||||
|
||||
local function send_headers(headers)
|
||||
@@ -81,16 +126,14 @@
|
||||
set_status(status or 500)
|
||||
send_headers(headers or {})
|
||||
common.send_content(res, res_iter, "send_data")
|
||||
+ elseif wsapi_env.STATUS == 404 then
|
||||
+ set_status(404)
|
||||
+ send_headers({ ["Content-Type"] = "text/html" })
|
||||
+ res:send_data(status)
|
||||
else
|
||||
- if wsapi_env.STATUS == 404 then
|
||||
- res.statusline = "HTTP/1.1 404"
|
||||
- send_headers({ ["Content-Type"] = "text/html" })
|
||||
- res:send_data(status)
|
||||
- else
|
||||
- res.statusline = "HTTP/1.1 500"
|
||||
- send_headers({ ["Content-Type"] = "text/html" })
|
||||
- res:send_data(common.error_html(status))
|
||||
- end
|
||||
+ set_status(500)
|
||||
+ send_headers({ ["Content-Type"] = "text/html" })
|
||||
+ res:send_data(common.error_html(status))
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in new issue