Class: IntervalResponse::Invalid

Inherits:
Abstract
  • Object
show all
Defined in:
lib/interval_response/invalid.rb

Overview

Serves out a response for 416 responses (invalid range request)

Constant Summary collapse

ERROR_JSON =
'{"message": "Ranges cannot be satisfied"}'

Instance Method Summary collapse

Methods inherited from Abstract

#etag, #initialize, #multiple_ranges?, #satisfied_with_first_interval?, #to_rack_response_triplet

Constructor Details

This class inherits a constructor from IntervalResponse::Abstract

Instance Method Details

#content_lengthObject



14
15
16
# File 'lib/interval_response/invalid.rb', line 14

def content_length
  ERROR_JSON.bytesize
end

#each {|ERROR_JSON, full_segment_range| ... } ⇒ Object

Yields:



5
6
7
8
# File 'lib/interval_response/invalid.rb', line 5

def each
  full_segment_range = (0..(ERROR_JSON.bytesize - 1))
  yield(ERROR_JSON, full_segment_range)
end

#headersObject



18
19
20
21
22
23
24
25
26
# File 'lib/interval_response/invalid.rb', line 18

def headers
  {
    'Accept-Ranges' => 'bytes',
    'Content-Length' => ERROR_JSON.bytesize.to_s,
    'Content-Type' => 'application/json',
    'Content-Range' => "bytes */#{@interval_sequence.size}",
    'ETag' => etag,
  }
end

#status_codeObject



10
11
12
# File 'lib/interval_response/invalid.rb', line 10

def status_code
  416
end