range()
public
Returns an Array of Range objects which represents Range: header field, or nil if there is no
such header.
Show source
def range
return nil unless @header['range']
self['Range'].split(/,/).map {|spec|
m = /bytes\s*=\s*(\d+)?\s*-\s*(\d+)?/.match(spec) or
raise HTTPHeaderSyntaxError, "wrong Range: #{spec}"
d1 = m[1].to_i
d2 = m[2].to_i
if m[1] and m[2] then d1..d2
elsif m[1] then d1..-1
elsif m[2] then -d2..-1
else
raise HTTPHeaderSyntaxError, 'range is not specified'
end
}
end