lib/goliath/connection.rb in goliath-0.9.1 vs lib/goliath/connection.rb in goliath-0.9.2
- old
+ new
@@ -1,7 +1,9 @@
require 'http/parser'
require 'goliath/env'
+require 'goliath/constants'
+require 'goliath/request'
module Goliath
# The Goliath::Connection class handles sending and receiving data
# from the client.
#
@@ -10,11 +12,11 @@
include Constants
attr_accessor :app, :api, :port, :logger, :status, :config, :options
attr_reader :parser
- AsyncResponse = [-1, {}, []].freeze
+ AsyncResponse = [-1, {}, []]
def post_init
@current = nil
@requests = []
@pending = []
@@ -74,10 +76,10 @@
def terminate_request(keep_alive)
if req = @pending.shift
@current = req
@current.succeed
- else
+ elsif @current
@current.close
@current = nil
end
close_connection_after_writing rescue nil if !keep_alive