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.
# File lib/chef/http/validate_content_length.rb, line 47 def handle_request(method, url, headers={}, data=false) [method, url, headers, data] end
# 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
# 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
Generated with the Darkfish Rdoc Generator 2.