Skip to content

Commit

Permalink
Adds keep alive support
Browse files Browse the repository at this point in the history
- Cleans up comments by removing obvious notes
- Moves "close" event to process_client
  • Loading branch information
despeset committed Apr 8, 2013
1 parent 196bf0e commit 1879fa0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Http/src/Http.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ function process_client(server::Server, client::Client, websockets_enabled::Bool
# Garbage collects parser globals on connection close
# see: `RequestParser.jl`
#
event("close", server, client)
clean!(client.parser)
end

Expand All @@ -207,7 +208,7 @@ function message_handler(server::Server, client::Client, websockets_enabled::Boo
return true
end

local response # Init response
local response

try
response = handle(server.http, req, Response()) # Run the server handler
Expand All @@ -216,16 +217,18 @@ function message_handler(server::Server, client::Client, websockets_enabled::Boo
end
catch err
response = Response(500)
event("error", server, client, err) # Something went wrong
event("error", server, client, err)
Base.display_error(err, catch_backtrace()) # Prints backtrace without throwing
end

response.headers["Content-Length"] = string(length(response.data))

write(client.sock, render(response)) # Send the response
write(client.sock, render(response))
event("write", server, client, response)
close(client.sock) # Close this connection
event("close", server, client)

if get(req.headers, "Connection", nothing) == "close"
close(client.sock)
end
end
end

Expand Down

0 comments on commit 1879fa0

Please sign in to comment.