#611 Serving static files doesn't work as advertised

Reporter Thijs Alkemade
Owner Zash
Created
Updated
Stars ★ (1)
Tags
  • Status-Fixed
  • mod_http_files
  • Type-Defect
  • Priority-Medium
  • Milestone-0.9
  1. Thijs Alkemade on

    I've followed the instructions on https://prosody.im/doc/developers/http#serving_files to serve static files from a module. However, it doesn't work, even with the example given on that page. The first problem is that it throws an exception: http.server error Traceback[httpserver]: ...ody/0.9/build/lib/prosody/modules/mod_http_files.lua:62: attempt to index local 'path' (a nil value) stack traceback: ...ody/0.9/build/lib/prosody/modules/mod_http_files.lua:62: in function 'sanitize_path' ...ody/0.9/build/lib/prosody/modules/mod_http_files.lua:92: in function '?' ...ojects/Prosody/0.9/build/lib/prosody/util/events.lua:67: in function 'fire_event' ...ts/Prosody/0.9/build/lib/prosody/net/http/server.lua:221: in function <...ts/Prosody/0.9/build/lib/prosody/net/http/server.lua:164> (tail call): ? [C]: in function 'xpcall' ...ts/Prosody/0.9/build/lib/prosody/net/http/server.lua:108: in function 'process_next' ...ts/Prosody/0.9/build/lib/prosody/net/http/server.lua:124: in function 'success_cb' ...ts/Prosody/0.9/build/lib/prosody/net/http/parser.lua:154: in function 'feed' ...ts/Prosody/0.9/build/lib/prosody/net/http/server.lua:150: in function <...ts/Prosody/0.9/build/lib/prosody/net/http/server.lua:149> (tail call): ? .../Prosody/0.9/build/lib/prosody/net/server_select.lua:867: in function <.../Prosody/0.9/build/lib/prosody/net/server_select.lua:849> [C]: in function 'xpcall' ./bin/prosody:376: in function 'loop' ./bin/prosody:407: in main chunk [C]: ? This seems to be due to serve_file receiving different arguments than it expects. I managed to fix this with https://code.xnyhps.nl/prosody/0.9/rev/92f892811d2b. The second problem is that when the path isn't a wildcard, it resolves the full path rather strangely. With the example from the wiki, it tries to read the file: /Users/thijs/Projects/Prosody/0.9/build/lib/prosody/modules/my_file.txt//mymodule/a_file.txt This is not what I expect, I expected it to look for just: /Users/thijs/Projects/Prosody/0.9/build/lib/prosody/modules/my_file.txt

  2. Thijs Alkemade on

    That second link should be: https://code.xnyhps.nl/prosody/0.9/rev/92f892811d2b

  3. Thijs Alkemade on

    Reading the rest of the code, the commit is probably wrong because it causes the second problem. I don't really understand how the directory listing code is supposed to work, so I can't propose a correct patch.

  4. Zash on

    This looks like a regression from #520.

    Changes
    • tags
  5. Zash on

    The code originally allowed for the path argument to be empty, it then used the entire configured path from the serve() call.

    Changes
    • tags
  6. Zash on

    OT: Where did this empty tag come from?

    Changes
    • tags
  7. Zash on

    Changes
    • tags mod_http_files
  8. Zash on

    Changes
    • owner Zash
    • tags Status-Started
  9. Zash on

    Fixed in http://hg.prosody.im/0.9/rev/b5b7ae2901e6 Testing appreciated

    Changes
    • tags Status-Fixed
  10. Zash on

    Changes
    • tags Milestone-0.9

New comment

Not published. Used for spam prevention and optional update notifications.