Class: Weary::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/em-net-http/weary.rb

Overview

Weary runs multi-threaded by default. The thread is spawned in perform!(). Let’s not do that.

Instance Method Summary collapse

Instance Method Details

#perform!(&block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/em-net-http/weary.rb', line 11

def perform!(&block)
  @on_complete = block if block_given?
  before_send.call(self) if before_send
  req = http.request(request)
  response = Response.new(req, self)
  if response.redirected? && follows?
    response.follow_redirect
  else
    on_complete.call(response) if on_complete
    response
  end
end