Module: Html2rss::RequestService::CompressedBody
- Defined in:
- lib/html2rss/request_service/compressed_body.rb
Overview
Decodes gzip/brotli bodies when Content-Encoding is missing or the type is octet-stream.
Constant Summary collapse
- GZIP_MAGIC =
Gzip stream magic (RFC 1952).
"\x1F\x8B".b.freeze
- HTML_BODY_SNIFF =
HTML prefix for unlabeled brotli trial decode. Same object as Response::HTML_BODY_SNIFF.
Response::HTML_BODY_SNIFF
Class Method Summary collapse
-
.decode(body, headers: {}) ⇒ String?
Decoded body when compressed; otherwise the original body.
Class Method Details
.decode(body, headers: {}) ⇒ String?
Returns decoded body when compressed; otherwise the original body.
21 22 23 24 25 26 |
# File 'lib/html2rss/request_service/compressed_body.rb', line 21 def decode(body, headers: {}) return body if body.nil? || body.empty? raw = body.to_s.b decode_labeled(raw, headers) || decode_unlabeled(raw, headers) || body end |