Class: Html2rss::RequestService::ResponseGuard
- Inherits:
-
Object
- Object
- Html2rss::RequestService::ResponseGuard
- Defined in:
- lib/html2rss/request_service/response_guard.rb
Overview
Enforces response-size limits before parsing.
Instance Method Summary collapse
-
#initialize(policy:) ⇒ ResponseGuard
constructor
A new instance of ResponseGuard.
-
#inspect_body!(body) ⇒ void
Validates the final response body after middleware processing.
Constructor Details
#initialize(policy:) ⇒ ResponseGuard
Returns a new instance of ResponseGuard.
10 11 12 |
# File 'lib/html2rss/request_service/response_guard.rb', line 10 def initialize(policy:) @policy = policy end |
Instance Method Details
#inspect_body!(body) ⇒ void
This method returns an undefined value.
Validates the final response body after middleware processing.
21 22 23 24 25 26 |
# File 'lib/html2rss/request_service/response_guard.rb', line 21 def inspect_body!(body) normalized_body = body.to_s size = normalized_body.bytesize raise_if_too_large!(size, policy.max_decompressed_bytes) raise_if_blocked_surface!(normalized_body) end |