Skip to content

Commit

Permalink
Make sure chunk is a string.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kami committed Jun 6, 2012
1 parent c4bae07 commit af3f000
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/luvit/http.lua
Expand Up @@ -369,6 +369,7 @@ function http.request(options, callback)
client.chunked = headers["Transfer-Encoding"] == "chunked"
if client.chunked then
client.write = function (self, chunk, callback)
chunk = chunk and chunk or ''
if #chunk > 0 then
original_write(self, stringFormat("%x\r\n", #chunk))
original_write(self, chunk)
Expand Down Expand Up @@ -463,6 +464,8 @@ function http.request(options, callback)
original_write = client.write
-- while connecting, we want to buffer writes and closes
client.write = function (self, chunk, callback)
chunk = chunk and chunk or ''
if #chunk > 0 then
if headers["Transfer-Encoding"] == "chunked" then
content[#content + 1] = stringFormat("%x\r\n%s\r\n", #chunk, chunk)
Expand Down

0 comments on commit af3f000

Please sign in to comment.