Class: Rstreamor::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/rstreamor/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Response

Returns a new instance of Response.



5
6
7
# File 'lib/rstreamor/response.rb', line 5

def initialize(request)
  @request = request
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



3
4
5
# File 'lib/rstreamor/response.rb', line 3

def request
  @request
end

Instance Method Details

#accept_rangesObject



25
26
27
# File 'lib/rstreamor/response.rb', line 25

def accept_ranges
  'bytes'
end

#cache_controlObject



29
30
31
# File 'lib/rstreamor/response.rb', line 29

def cache_control
  'no-cache'
end

#content_lengthObject



13
14
15
16
17
18
19
# File 'lib/rstreamor/response.rb', line 13

def content_length
  if request.range_header?
    (request.upper_bound - request.lower_bound + 1).to_s
  else
    request.file_size
  end
end

#content_rangeObject



21
22
23
# File 'lib/rstreamor/response.rb', line 21

def content_range
  "bytes #{request.lower_bound}-#{request.upper_bound}/#{request.file_size}"
end

#response_codeObject



9
10
11
# File 'lib/rstreamor/response.rb', line 9

def response_code
  request.range_header? ? 206 : 200
end