Module: Chef::HTTP::SocketlessChefZeroClient::ResponseExts

Defined in:
lib/chef/http/socketless_chef_zero_client.rb

Overview

This module is extended into Net::HTTP Response objects created from Socketless Chef Zero responses.

Instance Method Summary collapse

Instance Method Details

#read_body(dest = nil, &block) ⇒ Object

Net::HTTP raises an error if #read_body is called with a block or file argument after the body has already been read from the network.

Since we always set the body to the string response from Chef Zero and set the @read indicator variable, we have to patch this method or else streaming-style responses won't work.


64
65
66
67
68
69
70
71
72
73
74
# File 'lib/chef/http/socketless_chef_zero_client.rb', line 64

def read_body(dest = nil, &block)
  if dest
    raise "responses from socketless chef zero can't be written to specific destination"
  end

  if block_given?
    yield(@body)
  else
    super
  end
end