OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.5 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../lua-wsapi/status_names.patch
  5. # Copyright (C) 2009 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. --- ./src/wsapi/xavante.lua.orig 2009-06-02 16:30:03.000000000 +0200
  17. +++ ./src/wsapi/xavante.lua 2009-06-02 17:09:31.000000000 +0200
  18. @@ -4,6 +4,7 @@
  19. -- Author: Fabio Mascarenhas
  20. -- Copyright (c) 2007 Kepler Project
  21. --
  22. +-- vim: ts=3 cw=3 et:
  23. -----------------------------------------------------------------------------
  24. require "coxpcall"
  25. @@ -43,6 +44,49 @@
  26. end
  27. end
  28. +local status_name = {
  29. + [100] = "Continue",
  30. + [101] = "Switching Protocols",
  31. + [200] = "OK",
  32. + [201] = "Created",
  33. + [202] = "Accepted",
  34. + [203] = "Non-Authoritative Information",
  35. + [204] = "No Content",
  36. + [205] = "Reset Content",
  37. + [206] = "Partial Content",
  38. + [300] = "Multiple Choices",
  39. + [301] = "Moved Permanently",
  40. + [302] = "Found",
  41. + [303] = "See Other",
  42. + [304] = "Not Modified",
  43. + [305] = "Use Proxy",
  44. + [307] = "Temporary Redirect",
  45. + [400] = "Bad Request",
  46. + [401] = "Unauthorized",
  47. + [402] = "Payment Required",
  48. + [403] = "Forbidden",
  49. + [404] = "Not Found",
  50. + [405] = "Method Not Allowed",
  51. + [406] = "Not Acceptable",
  52. + [407] = "Proxy Authentication Required",
  53. + [408] = "Request Time-out",
  54. + [409] = "Conflict",
  55. + [410] = "Gone",
  56. + [411] = "Length Required",
  57. + [412] = "Precondition Failed",
  58. + [413] = "Request Entity Too Large",
  59. + [414] = "Request-URI Too Large",
  60. + [415] = "Unsupported Media Type",
  61. + [416] = "Requested range not satisfiable",
  62. + [417] = "Expectation Failed",
  63. + [500] = "Internal Server Error",
  64. + [501] = "Not Implemented",
  65. + [502] = "Bad Gateway",
  66. + [503] = "Service Unavailable",
  67. + [504] = "Gateway Time-out",
  68. + [505] = "HTTP Version not supported",
  69. +}
  70. +
  71. local function wsapihandler (req, res, wsapi_run, app_prefix, docroot, app_path)
  72. local path_info_pat = "^" .. (app_prefix or "") .. "(.*)"
  73. set_cgivars(req, docroot, path_info_pat, app_prefix)
  74. @@ -57,7 +101,8 @@
  75. wsapi_env.APP_PATH = app_path
  76. local function set_status(status)
  77. - res.statusline = "HTTP/1.1 " .. tostring(status)
  78. + res.statusline = string.format("HTTP/1.1 %d %s",
  79. + status, status_name[status] or "Unknown")
  80. end
  81. local function send_headers(headers)
  82. @@ -81,16 +126,14 @@
  83. set_status(status or 500)
  84. send_headers(headers or {})
  85. common.send_content(res, res_iter, "send_data")
  86. + elseif wsapi_env.STATUS == 404 then
  87. + set_status(404)
  88. + send_headers({ ["Content-Type"] = "text/html" })
  89. + res:send_data(status)
  90. else
  91. - if wsapi_env.STATUS == 404 then
  92. - res.statusline = "HTTP/1.1 404"
  93. - send_headers({ ["Content-Type"] = "text/html" })
  94. - res:send_data(status)
  95. - else
  96. - res.statusline = "HTTP/1.1 500"
  97. - send_headers({ ["Content-Type"] = "text/html" })
  98. - res:send_data(common.error_html(status))
  99. - end
  100. + set_status(500)
  101. + send_headers({ ["Content-Type"] = "text/html" })
  102. + res:send_data(common.error_html(status))
  103. end
  104. end