Class: Datastar::Compressor::Gzip

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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)
  @options = options.freeze
  @encoding = :gzip
  freeze
end

Instance Attribute Details

#encodingObject (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