aboutsummaryrefslogtreecommitdiff
path: root/src/http.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/http.lua')
-rw-r--r--src/http.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/http.lua b/src/http.lua
index 259eb2b..2c296d4 100644
--- a/src/http.lua
+++ b/src/http.lua
@@ -48,7 +48,7 @@ local function receiveheaders(sock, headers)
48 local line, name, value, err 48 local line, name, value, err
49 headers = headers or {} 49 headers = headers or {}
50 -- get first line 50 -- get first line
51 line, err = sock:receive() 51 line, err = sock:receive("*l")
52 if err then return nil, err end 52 if err then return nil, err end
53 -- headers go until a blank line is found 53 -- headers go until a blank line is found
54 while line ~= "" do 54 while line ~= "" do
@@ -57,12 +57,12 @@ local function receiveheaders(sock, headers)
57 if not (name and value) then return nil, "malformed response headers" end 57 if not (name and value) then return nil, "malformed response headers" end
58 name = string.lower(name) 58 name = string.lower(name)
59 -- get next line (value might be folded) 59 -- get next line (value might be folded)
60 line, err = sock:receive() 60 line, err = sock:receive("*l")
61 if err then return nil, err end 61 if err then return nil, err end
62 -- unfold any folded values 62 -- unfold any folded values
63 while string.find(line, "^%s") do 63 while string.find(line, "^%s") do
64 value = value .. line 64 value = value .. line
65 line, err = sock:receive() 65 line, err = sock:receive("*l")
66 if err then return nil, err end 66 if err then return nil, err end
67 end 67 end
68 -- save pair in table 68 -- save pair in table
@@ -82,7 +82,7 @@ socket.sourcet["http-chunked"] = function(sock, headers)
82 }, { 82 }, {
83 __call = function() 83 __call = function()
84 -- get chunk size, skip extension 84 -- get chunk size, skip extension
85 local line, err = sock:receive() 85 local line, err = sock:receive("*l")
86 if err then return nil, err end 86 if err then return nil, err end
87 local size = base.tonumber(string.gsub(line, ";.*", ""), 16) 87 local size = base.tonumber(string.gsub(line, ";.*", ""), 16)
88 if not size then return nil, "invalid chunk size" end 88 if not size then return nil, "invalid chunk size" end
@@ -90,7 +90,7 @@ socket.sourcet["http-chunked"] = function(sock, headers)
90 if size > 0 then 90 if size > 0 then
91 -- if not, get chunk and skip terminating CRLF 91 -- if not, get chunk and skip terminating CRLF
92 local chunk, err, _ = sock:receive(size) 92 local chunk, err, _ = sock:receive(size)
93 if chunk then sock:receive() end 93 if chunk then sock:receive("*l") end
94 return chunk, err 94 return chunk, err
95 else 95 else
96 -- if it was, read trailers into headers table 96 -- if it was, read trailers into headers table