Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid HTTP response status on WS script crash #23

Open
edzius opened this issue Oct 3, 2013 · 0 comments
Open

Invalid HTTP response status on WS script crash #23

edzius opened this issue Oct 3, 2013 · 0 comments

Comments

@edzius
Copy link

edzius commented Oct 3, 2013

If WS scripts crashes, server responds "HTTP/1.1 500" and in consequence Chrome/Firefox interprets status as "500 OK". It is not a critical bug but it doesn't look right. It should be "500 Internal Server Error".

There may be better approach solving this bug, however here is my fix:

diff --git a/lua-modules/wsapi-1.6/src/wsapi/xavante.lua b/lua-modules/wsapi-1.6/src/wsapi/xavante.lua
index 6c0bcec..38b29f3 100644
--- a/lua-modules/wsapi-1.6/src/wsapi/xavante.lua
+++ b/lua-modules/wsapi-1.6/src/wsapi/xavante.lua
@@ -93,12 +93,14 @@ local function wsapihandler (req, res, wsapi_run, app_prefix, docroot, app_path,
     common.send_content(res, res_iter, "send_data")
   else
     if wsapi_env.STATUS == 404 then
-      res.statusline = "HTTP/1.1 404"
+      -- Format proper HTTP status response with status code and string message
+      set_status(404)
       send_headers({ ["Content-Type"] = "text/html", ["Content-Length"] = (status and #status) or 0 })
       res:send_data(status)
     else
       local content = common.error_html(status)
-      res.statusline = "HTTP/1.1 500"
+      -- Format proper HTTP status response with status code and string message
+      set_status(500)
       send_headers({ ["Content-Type"] = "text/html", ["Content-Length"] = #content})
       res:send_data(content)
     end
-- 
1.7.10.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant