Skip to content

The hello world from the website is broken/function _M.find_file(filename) is called incorrectly #11

@rtzui

Description

@rtzui

How to reproduce the error:

  1. Install WSAPI with luarocks (locally)
    create a new file test.cgi with mode +x:
#!/usr/bin/env /home/user/.luarocks/bin/wsapi.cgi

module("test.cgi", package.seeall)

function run(wsapi_env)
  local headers = { ["Content-type"] = "text/html" }

  local function hello_text()
    coroutine.yield("<html><body>")
    coroutine.yield("<p>Hello Wsapi!</p>")
    coroutine.yield("<p>PATH_INFO: " .. wsapi_env.PATH_INFO .. "</p>")
    coroutine.yield("<p>SCRIPT_NAME: " .. wsapi_env.SCRIPT_NAME .. "</p>")
    coroutine.yield("</body></html>")
  end

  return 200, headers, coroutine.wrap(hello_text)
end

Run thttpd -p 8000 -d . -c \*.cgi as a webserver

Start web browser, get:

There was an error in the specified application. The full error message follows:

...me/user/.luarocks/share/lua/5.1//wsapi/common.lua:322: bad argument #1 to 'match' (string expected, got nil)
stack traceback:
    [C]: in function 'match'
    ...me/user/.luarocks/share/lua/5.1//wsapi/common.lua:322: in function 'splitext'
    ...me/user/.luarocks/share/lua/5.1//wsapi/common.lua:342: in function <...me/user/.luarocks/share/lua/5.1//wsapi/common.lua:332>
    (tail call): ?
    ...uarocks/lib/luarocks/rocks/wsapi/cvs-4/bin/wsapi.cgi:15: in function <...uarocks/lib/luarocks/rocks/wsapi/cvs-4/bin/wsapi.cgi:13>
    (tail call): ?
    [C]: in function 'xpcall'
    ...me/user/.luarocks/share/lua/5.1//wsapi/common.lua:264: in function 'run_app'
    ...me/user/.luarocks/share/lua/5.1//wsapi/common.lua:291: in function 'run'
    /home/user/.luarocks/share/lua/5.1//wsapi/cgi.lua:19: in function 'run'
    ...uarocks/lib/luarocks/rocks/wsapi/cvs-4/bin/wsapi.cgi:25: in main chunk
    [C]: ?

The Problem seems to be that _M.find_file(filename) from common.lua gets only the name of the file to be run, not a path to it. But I'm not sure. I'm, by the way, using lua5.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions