Class: Datastar::Compressor::Gzip
- Inherits:
-
Object
- Object
- Datastar::Compressor::Gzip
- Defined in:
- lib/datastar/compressor/gzip.rb
Overview
Gzip compressor — built once at config time, reused across requests.
Defined Under Namespace
Classes: CompressedSocket
Instance Attribute Summary collapse
-
#encoding ⇒ Object
readonly
Returns the value of attribute encoding.
Instance Method Summary collapse
-
#initialize(options) ⇒ Gzip
constructor
A new instance of Gzip.
- #prepare_response(response) ⇒ Object
- #wrap_socket(socket) ⇒ Object
Constructor Details
#initialize(options) ⇒ Gzip
Returns a new instance of Gzip.
11 12 13 14 15 |
# File 'lib/datastar/compressor/gzip.rb', line 11 def initialize() @options = .freeze @encoding = :gzip freeze end |
Instance Attribute Details
#encoding ⇒ Object (readonly)
Returns the value of attribute encoding.
9 10 11 |
# File 'lib/datastar/compressor/gzip.rb', line 9 def encoding @encoding end |
Instance Method Details
#prepare_response(response) ⇒ Object
17 18 19 20 |
# File 'lib/datastar/compressor/gzip.rb', line 17 def prepare_response(response) response.headers['Content-Encoding'] = 'gzip' response.headers['Vary'] = 'Accept-Encoding' end |
#wrap_socket(socket) ⇒ Object
22 23 24 |
# File 'lib/datastar/compressor/gzip.rb', line 22 def wrap_socket(socket) CompressedSocket.new(socket, @options) end |