module Chef::HTTP::SocketlessChefZeroClient::ResponseExts

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

Public Instance Methods

read_body(dest = nil) { |body| ... } click to toggle source

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.

Calls superclass method
# File lib/chef/http/socketless_chef_zero_client.rb, line 68
def read_body(dest = nil, &block)
  if dest
    raise "responses from socketless #{ChefUtils::Dist::Zero::PRODUCT} can't be written to specific destination"
  end

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