Parent

Files

Class/Module Index [+]

Quicksearch

Chef::HTTP::ValidateContentLength

Middleware that validates the Content-Length header against the downloaded number of bytes.

This must run before the decompressor middleware, since otherwise we will count the uncompressed streamed bytes, rather than the on-the-wire compressed bytes.

Public Class Methods

new(opts={}) click to toggle source
# File lib/chef/http/validate_content_length.rb, line 44
def initialize(opts={})
end

Public Instance Methods

handle_request(method, url, headers={}, data=false) click to toggle source
# File lib/chef/http/validate_content_length.rb, line 47
def handle_request(method, url, headers={}, data=false)
  [method, url, headers, data]
end
handle_response(http_response, rest_request, return_value) click to toggle source
# File lib/chef/http/validate_content_length.rb, line 51
def handle_response(http_response, rest_request, return_value)
  validate(http_response, http_response.body.bytesize) if http_response && http_response.body
  return [http_response, rest_request, return_value]
end
handle_stream_complete(http_response, rest_request, return_value) click to toggle source
# File lib/chef/http/validate_content_length.rb, line 56
def handle_stream_complete(http_response, rest_request, return_value)
  if @content_length_counter.nil?
    Chef::Log.debug("No content-length information collected for the streamed download, cannot identify streamed download.")
  else
    validate(http_response, @content_length_counter.content_length)
  end

  # Make sure the counter is reset since this object might get used
  # again. See CHEF-5100
  @content_length_counter = nil
  return [http_response, rest_request, return_value]
end
stream_response_handler(response) click to toggle source
# File lib/chef/http/validate_content_length.rb, line 69
def stream_response_handler(response)
  @content_length_counter = ContentLengthCounter.new
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.