Class: Chef::HTTP::ValidateContentLength
- Inherits:
-
Object
- Object
- Chef::HTTP::ValidateContentLength
show all
- Defined in:
- lib/chef/http/validate_content_length.rb
Overview
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.
Defined Under Namespace
Classes: ContentLengthCounter
Instance Method Summary
collapse
Constructor Details
44
45
|
# File 'lib/chef/http/validate_content_length.rb', line 44
def initialize(opts={})
end
|
Instance Method Details
#handle_request(method, url, headers = {}, data = false) ⇒ Object
47
48
49
|
# File 'lib/chef/http/validate_content_length.rb', line 47
def handle_request(method, url, ={}, data=false)
[method, url, , data]
end
|
#handle_response(http_response, rest_request, return_value) ⇒ Object
51
52
53
54
|
# 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) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
|
# 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
@content_length_counter = nil
return [http_response, rest_request, return_value]
end
|
#stream_response_handler(response) ⇒ Object
69
70
71
|
# File 'lib/chef/http/validate_content_length.rb', line 69
def stream_response_handler(response)
@content_length_counter = ContentLengthCounter.new
end
|