diff --git a/lib/right_http_connection.rb b/lib/right_http_connection.rb index 7db1378..428f631 100644 --- a/lib/right_http_connection.rb +++ b/lib/right_http_connection.rb @@ -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. @@ -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 @@ -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