module Ethon::Easy::ResponseCallbacks
def body(chunk)
-
(Object)
- If there are no on_body callbacks, returns the symbol :unyielded.
Other tags:
- Example: Execute on_body. -
def body(chunk) if defined?(@on_body) and not @on_body.nil? result = nil @on_body.each do |callback| result = callback.call(chunk, self) break if result == :abort end result else :unyielded end end
def complete
- Example: Execute on_completes. -
def complete headers unless @response_headers.empty? if defined?(@on_complete) and not @on_complete.nil? @on_complete.each{ |callback| callback.call(self) } end end
def headers
- Example: Execute on_headers. -
def headers return if @headers_called @headers_called = true if defined?(@on_headers) and not @on_headers.nil? result = nil @on_headers.each do |callback| result = callback.call(self) break if result == :abort end result end end
def on_body(&block)
-
block
(Block
) -- The block to execute.
Other tags:
- Example: Set on_body. -
def on_body(&block) @on_body ||= [] @on_body << block if block_given? @on_body end
def on_complete(&block)
-
block
(Block
) -- The block to execute.
Other tags:
- Example: Set on_complete. -
def on_complete(&block) @on_complete ||= [] @on_complete << block if block_given? @on_complete end
def on_headers(&block)
-
block
(Block
) -- The block to execute.
Other tags:
- Example: Set on_headers. -
def on_headers(&block) @on_headers ||= [] @on_headers << block if block_given? @on_headers end
def on_progress(&block)
-
block
(Block
) -- The block to execute.
Other tags:
- Example: Set on_progress. -
def on_progress(&block) @on_progress ||= [] if block_given? @on_progress << block set_progress_callback self.noprogress = 0 end @on_progress end
def progress(dltotal, dlnow, ultotal, ulnow)
- Example: Execute on_progress. -
def progress(dltotal, dlnow, ultotal, ulnow) if defined?(@on_progress) and not @on_progress.nil? @on_progress.each{ |callback| callback.call(dltotal, dlnow, ultotal, ulnow) } end end