diff options
-rw-r--r-- | lib/chef/http/validate_content_length.rb (renamed from lib/chef/http/validate_response.rb) | 7 | ||||
-rw-r--r-- | lib/chef/rest.rb | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/chef/http/validate_response.rb b/lib/chef/http/validate_content_length.rb index 1eaef3fa91..37305be756 100644 --- a/lib/chef/http/validate_response.rb +++ b/lib/chef/http/validate_content_length.rb @@ -22,8 +22,11 @@ require 'chef/log' class Chef class HTTP - # Middleware that takes an HTTP response, parses it as JSON if possible. - class ValidateResponse + # 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. + class ValidateContentLength class ContentLengthCounter attr_accessor :content_length diff --git a/lib/chef/rest.rb b/lib/chef/rest.rb index c96411203b..a1139d7fa2 100644 --- a/lib/chef/rest.rb +++ b/lib/chef/rest.rb @@ -32,7 +32,7 @@ require 'chef/http/decompressor' require 'chef/http/json_input' require 'chef/http/json_to_model_output' require 'chef/http/cookie_manager' -require 'chef/http/validate_response' +require 'chef/http/validate_content_length' require 'chef/config' require 'chef/exceptions' require 'chef/platform/query_helpers' @@ -63,7 +63,7 @@ class Chef @decompressor = Decompressor.new(options) @authenticator = Authenticator.new(options) - @middlewares << ValidateResponse.new(options) + @middlewares << ValidateContentLength.new(options) @middlewares << JSONInput.new(options) @middlewares << JSONToModelOutput.new(options) @middlewares << CookieManager.new(options) |