lua-http
lua-http copied to clipboard
Invalid request causes infinite loop on http.server
Sending a malformed request to any http.server will cause it to indefinitely call the onstream function. How to replicate:
- run any http.server e.g.
examples/server_hello.lua - create the request:
echo -e -n "GET / HTTP/1.1\r\n\r\n\r\n" > requestThe file will look like this:
$ hexdump -C request
00000000 47 45 54 20 2f 20 48 54 54 50 2f 31 2e 31 0d 0a |GET / HTTP/1.1..|
00000010 0d 0a 0d 0a |....|
- send the request:
nc 127.0.0.1 80 < request
The request will show up in the lua stdout and the server will respond as usual. However you will see that the connection in netcat has not been closed yet. If you now terminate netcat by pressing ctrl+c the server will indefinitely call the onstream callback.
Unfortunately I could not find a way to prevent this or block the request from outside the module. To me it looks like the server is still waiting for data?