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

Fix receiveheaders function #420

Merged
merged 1 commit into from
Nov 13, 2023
Merged

Conversation

AMD-NICK
Copy link
Contributor

It seems that error checking is needed here, otherwise in theory there will be an error in the while loop if line becomes false

looks like it should be here
@AMD-NICK
Copy link
Contributor Author

Lua Test code:

local http = require("socket.http")
local _, err = http.request("http://dev:port", "")
print("err", err)

nodejs

const net = require('net');

const server = net.createServer((socket) => {
    socket.write("HTTP/1.1 200 OK\r\n");
    socket.write("Content-Type: text/plain\r\n");
    socket.write("X-Custom-Header: key=val;\r\n");
	socket.write("    foo=bar;\r\n")
	socket.end(); // <<----------------------------------
	socket.write("    bar=baz;\r\n")
    socket.write("\r\n");
    socket.write("Hello, World!\r\n");
    
    socket.end();
});

const PORT = 8000;
server.listen(PORT, () => {
    console.log(`Server listening on port ${PORT}`);
});

Without fix:

......./share/lua/5.1/socket/http.lua:50: bad argument #1 to 'find' (string expected, got nil)

with:

err closed

@alerque
Copy link
Member

alerque commented Nov 13, 2023

Thanks for taking the time to track this down and contribute a fix.

@alerque alerque merged commit 13f2b3c into lunarmodules:master Nov 13, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants