Class: PersistentConnectionAdapter::PersistentHTTP

Inherits:
Net::HTTP
  • Object
show all
Defined in:
lib/resthome/httparty/persistent_connection_adapter.rb

Overview

basically just reconnect if you get an EOFError

Instance Method Summary collapse

Instance Method Details

#request_with_retry(req, body = nil, &block) ⇒ Object Also known as: request



5
6
7
8
9
10
11
12
13
# File 'lib/resthome/httparty/persistent_connection_adapter.rb', line 5

def request_with_retry(req, body = nil, &block)
  begin
    request_without_retry req, body, &block
  rescue EOFError => e # means the server closed the connection most likely
    @socket.close if @socket and not @socket.closed?
    connect
    request_without_retry req, body, &block
  end
end