Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/right_http_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def eof_time
# Returns true if we are receiving EOFs during last @params[:http_connection_retry_delay] seconds
# and there were no successful response from server
def raise_on_eof_exception?
@@eof[@server].blank? ? false : ((Time.now.to_i-@params[:http_connection_retry_delay]) > @@eof[@server].last.to_i)
blank?(@@eof[@server]) ? false : ((Time.now.to_i-@params[:http_connection_retry_delay]) > @@eof[@server].last.to_i)
end

# Reset a list of EOFs for this server.
Expand Down Expand Up @@ -302,6 +302,18 @@ def start(request_params)
@http.start
end

def blank?(var)
if var.respond_to?(:blank?)
var.blank?
elsif var.respond_to?(:empty?) && var.respond_to?(:strip)
var.empty? or var.strip.empty?
elsif var.respond_to?(:empty?)
var.empty?
else
!var
end
end

public

=begin rdoc
Expand Down Expand Up @@ -406,7 +418,7 @@ def request(request_params, &block)

def finish(reason = '')
if @http && @http.started?
reason = ", reason: '#{reason}'" unless reason.blank?
reason = ", reason: '#{reason}'" unless blank?(reason)
@logger.info("Closing #{@http.use_ssl? ? 'HTTPS' : 'HTTP'} connection to #{@http.address}:#{@http.port}#{reason}")
@http.finish
end
Expand Down