Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
http: first working client. - fixes some syntax errors
  • Loading branch information
Ryan Phillips committed Jun 22, 2012
1 parent a006444 commit fe61ead
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/luvit/http.lua
Expand Up @@ -416,7 +416,7 @@ function OutgoingMessage:write(chunk, encoding)
return true
end
if #chunk == 0 then
if not chunk or #chunk == 0 then
return false
end
Expand Down Expand Up @@ -706,6 +706,7 @@ function ClientRequest:onSocket(socket)
socket:on('close', function()
end)
socket:on('end', function()
self.socket:destroy()
end)
socket:on('data', function(chunk)
p(chunk)
Expand All @@ -719,13 +720,14 @@ function ClientRequest:onSocket(socket)
return
end
local nparsed = parser:execute(chunk, 0, #chunk)
local nparsed = self.parser:execute(chunk, 0, #chunk)
-- If it wasn't all parsed then there was an error parsing
if nparsed < #chunk then
response:emit("error", "parse error")
end
end)
socket:on('error', function(err)
self:emit('error', err)
end)
self:emit('socket', socket)
end)
Expand Down

0 comments on commit fe61ead

Please sign in to comment.