mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
bugfix: use temp array for each request
This commit is contained in:
@@ -64,16 +64,11 @@ local function recvheader(readbytes, limit, lines, header)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local idx = 1
|
|
||||||
for v in header:gmatch("(.-)\r\n") do
|
for v in header:gmatch("(.-)\r\n") do
|
||||||
if v == "" then
|
if v == "" then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
lines[idx] = v
|
table.insert(lines, v)
|
||||||
idx = idx + 1
|
|
||||||
end
|
|
||||||
for i = idx, #lines do
|
|
||||||
lines[i] = nil
|
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
@@ -131,8 +126,6 @@ local function readcrln(readbytes, body)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local tmpline = {}
|
|
||||||
|
|
||||||
local function recvchunkedbody(readbytes, bodylimit, header, body)
|
local function recvchunkedbody(readbytes, bodylimit, header, body)
|
||||||
local result = ""
|
local result = ""
|
||||||
local size = 0
|
local size = 0
|
||||||
@@ -167,6 +160,7 @@ local function recvchunkedbody(readbytes, bodylimit, header, body)
|
|||||||
if not body then
|
if not body then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local tmpline = {}
|
||||||
body = recvheader(readbytes, 8192, tmpline, body)
|
body = recvheader(readbytes, 8192, tmpline, body)
|
||||||
if not body then
|
if not body then
|
||||||
return
|
return
|
||||||
@@ -178,6 +172,7 @@ local function recvchunkedbody(readbytes, bodylimit, header, body)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function readall(readbytes, bodylimit)
|
local function readall(readbytes, bodylimit)
|
||||||
|
local tmpline = {}
|
||||||
local body = recvheader(readbytes, 8192, tmpline, "")
|
local body = recvheader(readbytes, 8192, tmpline, "")
|
||||||
if not body then
|
if not body then
|
||||||
return 413 -- Request Entity Too Large
|
return 413 -- Request Entity Too Large
|
||||||
|
|||||||
@@ -28,4 +28,16 @@ function sockethelper.writefunc(fd)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function sockethelper.connect(host, port)
|
||||||
|
local fd = socket.open(host, port)
|
||||||
|
if fd then
|
||||||
|
return fd
|
||||||
|
end
|
||||||
|
error(socket_error)
|
||||||
|
end
|
||||||
|
|
||||||
|
function sockethelper.close(fd)
|
||||||
|
socket.close(fd)
|
||||||
|
end
|
||||||
|
|
||||||
return sockethelper
|
return sockethelper
|
||||||
|
|||||||
Reference in New Issue
Block a user