range_header_parser 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +8 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +20 -0
- data/README.md +34 -0
- data/Rakefile +52 -0
- data/authorization_header_parser.gemspec +58 -0
- data/lib/range_header_parser.rb +66 -0
- data/lib/range_header_parser/version.rb +3 -0
- data/range_header_parser.gemspec +63 -0
- data/spec/range_header_parser_spec.rb +119 -0
- data/spec/spec_helper.rb +9 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 217f64dd018bb6c66a7d38805273d4acac2c7dca
|
4
|
+
data.tar.gz: c19c42981bc33331d5c5ff52161df8c01b0e515b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6fcd582622c18bd2072344c24ddf523796bf0d5ebf27c6e6b61c508625ced22a2f2f30782cc64e140947bac7ff53d18e03285feb56fd643bc44980e08f958a33
|
7
|
+
data.tar.gz: 1e41f056d1bac4305889cbbd53959c0ee4fa455a0bd2a1958e81b5431752b243264af01e19ffc69568a09e5057360f917c0c19c1fad80af5cd1e0ea5810b8921
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2015 WeTransfer
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# range_header_parser
|
2
|
+
|
3
|
+
![Travis-CI status](https://api.travis-ci.org/wetransfer/range_header_parser.svg?branch=master)
|
4
|
+
|
5
|
+
Parse `Range:` HTTP headers, and returns an Array of Ruby ranges. The ranges are guaranteed to be:
|
6
|
+
|
7
|
+
* positive
|
8
|
+
* inclusive
|
9
|
+
* of at least 1 byte
|
10
|
+
|
11
|
+
Use it like so:
|
12
|
+
|
13
|
+
if env['HTTP_RANGE']
|
14
|
+
ranges = RangeHeaderParser.parse(env['HTTP_RANGE], size_of_resource)
|
15
|
+
end
|
16
|
+
|
17
|
+
Adjacent ranges will be combined. Note that returning multiple ranges requires a multipart/byteranges
|
18
|
+
response, and you might need some special machinery to be able to generate it.
|
19
|
+
|
20
|
+
## Contributing to range_header_parser
|
21
|
+
|
22
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
23
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
24
|
+
* Fork the project.
|
25
|
+
* Start a feature/bugfix branch.
|
26
|
+
* Commit and push until you are happy with your contribution.
|
27
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
28
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
29
|
+
|
30
|
+
## Copyright
|
31
|
+
|
32
|
+
Copyright (c) 2015 WeTransfer. See LICENSE.txt for
|
33
|
+
further details.
|
34
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require_relative 'lib/range_header_parser/version'
|
15
|
+
|
16
|
+
require 'jeweler'
|
17
|
+
Jeweler::Tasks.new do |gem|
|
18
|
+
gem.version = RangeHeaderParser::VERSION
|
19
|
+
gem.name = "range_header_parser"
|
20
|
+
gem.homepage = "http://github.com/wetransfer/range_header_parser"
|
21
|
+
gem.license = "MIT"
|
22
|
+
gem.description = %Q{Parses Range HTTP headers for specific fetches}
|
23
|
+
gem.summary = %Q{with range splicing and proper offsets}
|
24
|
+
gem.email = "me@julik.nl"
|
25
|
+
gem.authors = ["Julik Tarkhanov"]
|
26
|
+
# dependencies defined in Gemfile
|
27
|
+
end
|
28
|
+
Jeweler::RubygemsDotOrgTasks.new
|
29
|
+
|
30
|
+
require 'rspec/core'
|
31
|
+
require 'rspec/core/rake_task'
|
32
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
33
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Code coverage detail"
|
37
|
+
task :simplecov do
|
38
|
+
ENV['COVERAGE'] = "true"
|
39
|
+
Rake::Task['spec'].execute
|
40
|
+
end
|
41
|
+
|
42
|
+
task :default => :spec
|
43
|
+
|
44
|
+
require 'rdoc/task'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
|
+
|
48
|
+
rdoc.rdoc_dir = 'rdoc'
|
49
|
+
rdoc.title = "range_header_parser #{version}"
|
50
|
+
rdoc.rdoc_files.include('README*')
|
51
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: range_header_parser 1.0.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "range_header_parser"
|
9
|
+
s.version = "1.0.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Julik Tarkhanov"]
|
14
|
+
s.date = "2015-06-29"
|
15
|
+
s.description = "Parses parametrized HTTP Authorization headers"
|
16
|
+
s.email = "me@julik.nl"
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".rspec",
|
24
|
+
"Gemfile",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.md",
|
27
|
+
"Rakefile",
|
28
|
+
"lib/range_header_parser.rb",
|
29
|
+
"spec/range_header_parser_spec.rb",
|
30
|
+
"spec/spec_helper.rb"
|
31
|
+
]
|
32
|
+
s.homepage = "http://github.com/julik/range_header_parser"
|
33
|
+
s.licenses = ["MIT"]
|
34
|
+
s.rubygems_version = "2.2.2"
|
35
|
+
s.summary = "such as OAuth and Digest"
|
36
|
+
|
37
|
+
if s.respond_to? :specification_version then
|
38
|
+
s.specification_version = 4
|
39
|
+
|
40
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
41
|
+
s.add_development_dependency(%q<rspec>, ["~> 3"])
|
42
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
43
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
44
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
45
|
+
else
|
46
|
+
s.add_dependency(%q<rspec>, ["~> 3"])
|
47
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
48
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
49
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
50
|
+
end
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<rspec>, ["~> 3"])
|
53
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
54
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
55
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'range_utils'
|
2
|
+
|
3
|
+
module RangeHeaderParser
|
4
|
+
RANGE_RE = /^(\d+)-(\d+)$/.freeze
|
5
|
+
RANGE_FROM = /^(\d+)-$/.freeze
|
6
|
+
RANGE_LAST_N =/^-(\d+)$/.freeze
|
7
|
+
BYTES_RE = /^bytes=(.*)/.freeze
|
8
|
+
|
9
|
+
InvalidHeader = Class.new(RuntimeError)
|
10
|
+
InvalidRange = Class.new(InvalidHeader)
|
11
|
+
|
12
|
+
# Parses a given string from Range: header,
|
13
|
+
# and returns an Array of Range objects.
|
14
|
+
#
|
15
|
+
# Overlapping and adjacent ranges will be spliced.
|
16
|
+
def parse(header_str, resource_size)
|
17
|
+
ranges = ranges_from_header_str(header_str, resource_size)
|
18
|
+
RangeUtils.splice(ranges)
|
19
|
+
end
|
20
|
+
|
21
|
+
extend self
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# Ported from WEBrick::HTTPUtils.parse_range_header, but with extra juice and
|
26
|
+
# honoring the actual size of the resource.
|
27
|
+
# https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1
|
28
|
+
# If the last-byte-pos value is absent, or if the value is greater than or equal
|
29
|
+
# to the current length of the entity-body, last-byte-pos is taken to be equal
|
30
|
+
# to one less than the current length of the entity- body in bytes.
|
31
|
+
def ranges_from_header_str(ranges_specifier, size)
|
32
|
+
raise InvalidHeader, ranges_specifier unless BYTES_RE =~ ranges_specifier
|
33
|
+
byte_range_set = split_header_value($1)
|
34
|
+
byte_range_set.map do |range_spec|
|
35
|
+
case range_spec
|
36
|
+
when RANGE_RE # From byte M to byte N
|
37
|
+
starts_at = $1.to_i
|
38
|
+
ends_at = $2.to_i
|
39
|
+
ends_at = (size - 1) if ends_at >= size
|
40
|
+
raise InvalidRange, "Invalid range spec #{range_spec} (starts too far in the resource)" if starts_at >= size
|
41
|
+
raise InvalidRange, "Invalid range spec #{range_spec} (start and end are flipped)" if ends_at < starts_at
|
42
|
+
starts_at..ends_at
|
43
|
+
when RANGE_FROM # From byte N to the end
|
44
|
+
starts_at = $1.to_i
|
45
|
+
raise InvalidRange, "Invalid range spec (starts too far in the resource) #{range_spec}" if starts_at >= size
|
46
|
+
starts_at..(size - 1)
|
47
|
+
when RANGE_LAST_N # The last N bytes
|
48
|
+
last_n = $1.to_i
|
49
|
+
raise InvalidRange, "Invalid range spec #{range_spec} (resource too small)" if last_n > size
|
50
|
+
|
51
|
+
starts_at = size - last_n
|
52
|
+
ends_at = size - 1
|
53
|
+
raise InvalidRange, "Invalid range spec #{range_spec} (flipped negative)" if starts_at >= size
|
54
|
+
starts_at..ends_at
|
55
|
+
else
|
56
|
+
raise InvalidRange, "Invalid range spec #{range_spec} (unparseable)"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Ported from webrick
|
62
|
+
def split_header_value(str)
|
63
|
+
str.scan(%r'\G((?:"(?:\.|[^"])+?"|[^",]+)+)
|
64
|
+
(?:,\s*|\Z)'xn).flatten
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: range_header_parser 1.0.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "range_header_parser"
|
9
|
+
s.version = "1.0.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Julik Tarkhanov"]
|
14
|
+
s.date = "2016-05-18"
|
15
|
+
s.description = "Parses Range HTTP headers for specific fetches"
|
16
|
+
s.email = "me@julik.nl"
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".travis.yml",
|
23
|
+
"Gemfile",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.md",
|
26
|
+
"Rakefile",
|
27
|
+
"authorization_header_parser.gemspec",
|
28
|
+
"lib/range_header_parser.rb",
|
29
|
+
"lib/range_header_parser/version.rb",
|
30
|
+
"range_header_parser.gemspec",
|
31
|
+
"spec/range_header_parser_spec.rb",
|
32
|
+
"spec/spec_helper.rb"
|
33
|
+
]
|
34
|
+
s.homepage = "http://github.com/wetransfer/range_header_parser"
|
35
|
+
s.licenses = ["MIT"]
|
36
|
+
s.rubygems_version = "2.2.2"
|
37
|
+
s.summary = "with range splicing and proper offsets"
|
38
|
+
|
39
|
+
if s.respond_to? :specification_version then
|
40
|
+
s.specification_version = 4
|
41
|
+
|
42
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
43
|
+
s.add_runtime_dependency(%q<range_utils>, [">= 0"])
|
44
|
+
s.add_development_dependency(%q<rspec>, ["~> 3"])
|
45
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
46
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
47
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<range_utils>, [">= 0"])
|
50
|
+
s.add_dependency(%q<rspec>, ["~> 3"])
|
51
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
52
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
53
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
54
|
+
end
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<range_utils>, [">= 0"])
|
57
|
+
s.add_dependency(%q<rspec>, ["~> 3"])
|
58
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
59
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
60
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe RangeHeaderParser do
|
4
|
+
it 'parses the various versions correctly and splices overlapping/adjacent byte ranges' do
|
5
|
+
size = 10000
|
6
|
+
expect(described_class.parse('bytes=0-499', 10000)).to eq([0..499])
|
7
|
+
expect(described_class.parse('bytes=500-999', 10000)).to eq([500..999])
|
8
|
+
|
9
|
+
expect(described_class.parse('bytes=-500', 10000)).to eq([9500..9999])
|
10
|
+
expect(described_class.parse('bytes=9500-', 10000)).to eq([9500..9999])
|
11
|
+
|
12
|
+
expect(described_class.parse('bytes=500-520,601-999', 10000)).to eq([500..520, 601..999])
|
13
|
+
|
14
|
+
expect(described_class.parse('bytes=500-600,601-999', 10000)).to eq([500..999])
|
15
|
+
expect(described_class.parse('bytes=601-999,500-600', 10000)).to eq([500..999])
|
16
|
+
expect(described_class.parse('bytes=500-700,601-999', 10000)).to eq([500..999])
|
17
|
+
|
18
|
+
expect(described_class.parse('bytes=500-600,1000-1024,601-999', 10000)).to eq([500..1024])
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'bails when encountering nonsensical ranges' do
|
22
|
+
expect {
|
23
|
+
described_class.parse('bytes=-1--13', 1)
|
24
|
+
}.to raise_error(described_class::InvalidRange, 'Invalid range spec -1--13 (unparseable)')
|
25
|
+
|
26
|
+
expect {
|
27
|
+
described_class.parse('bytes=1-13', 1)
|
28
|
+
}.to raise_error(described_class::InvalidRange, 'Invalid range spec 1-13 (starts too far in the resource)')
|
29
|
+
|
30
|
+
expect {
|
31
|
+
described_class.parse('bytes=-999999', 1)
|
32
|
+
}.to raise_error(described_class::InvalidRange, 'Invalid range spec -999999 (resource too small)')
|
33
|
+
|
34
|
+
expect {
|
35
|
+
described_class.parse('bytes=12345-12', 999999)
|
36
|
+
}.to raise_error(described_class::InvalidRange, 'Invalid range spec 12345-12 (start and end are flipped)')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'handles examples from the RFC 2616' do
|
40
|
+
# https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1
|
41
|
+
# Examples of byte-ranges-specifier values (assuming an entity-body of length 10000):
|
42
|
+
size = 10000
|
43
|
+
|
44
|
+
# The first 500 bytes (byte offsets 0-499, inclusive):
|
45
|
+
parsed_ranges = described_class.parse('bytes=0-499', size)
|
46
|
+
expect(parsed_ranges).to be_one
|
47
|
+
range = parsed_ranges.first
|
48
|
+
expect(range.to_a.length).to eq(500)
|
49
|
+
expect(range).to eq(0..499)
|
50
|
+
|
51
|
+
# The second 500 bytes (byte offsets 500-999, inclusive):
|
52
|
+
parsed_ranges = described_class.parse('bytes=500-999', size)
|
53
|
+
expect(parsed_ranges).to be_one
|
54
|
+
range = parsed_ranges.first
|
55
|
+
expect(range.to_a.length).to eq(500)
|
56
|
+
expect(range).to eq(500..999)
|
57
|
+
|
58
|
+
# The final 500 bytes (byte offsets 9500-9999, inclusive):
|
59
|
+
range = described_class.parse('bytes=-500', size).first
|
60
|
+
expect(range.to_a.length).to eq(500)
|
61
|
+
expect(range).to eq(9500..9999)
|
62
|
+
range = described_class.parse('bytes=9500-', size).first
|
63
|
+
expect(range.to_a.length).to eq(500)
|
64
|
+
expect(range).to eq(9500..9999)
|
65
|
+
|
66
|
+
# The first and last bytes only (bytes 0 and 9999):
|
67
|
+
a, b = described_class.parse('bytes=0-0,-1', size)
|
68
|
+
expect(a).to eq(0..0)
|
69
|
+
expect(b).to eq(9999..9999)
|
70
|
+
|
71
|
+
# Several legal but not canonical specifications of the second 500
|
72
|
+
# bytes (byte offsets 500-999, inclusive):
|
73
|
+
%w( bytes=500-600,601-999 bytes=500-700,601-999).each do |bytespec|
|
74
|
+
ranges = described_class.parse(bytespec, size)
|
75
|
+
expect(ranges).to be_one
|
76
|
+
range = ranges.first
|
77
|
+
expect(range).to eq(500..999)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'clamps ranges' do
|
82
|
+
size = 100
|
83
|
+
expect(described_class.parse('bytes=0-499', size)).to eq([0..99])
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'bails on invalid headers' do
|
87
|
+
%w(
|
88
|
+
tingies=100-200
|
89
|
+
100-200
|
90
|
+
not-a-header-value-at-all
|
91
|
+
).each do | garbage |
|
92
|
+
expect {
|
93
|
+
described_class.parse(garbage, 10000)
|
94
|
+
}.to raise_error(described_class::InvalidHeader, /#{Regexp.escape(garbage)}/)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'bails on negative ranges' do
|
99
|
+
%w(
|
100
|
+
bytes=3-0
|
101
|
+
).each do | garbage |
|
102
|
+
expect {
|
103
|
+
described_class.parse(garbage, 10000)
|
104
|
+
}.to raise_error(described_class::InvalidRange)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'bails on invalid ranges' do
|
109
|
+
%w(
|
110
|
+
bytes=-
|
111
|
+
bytes=more
|
112
|
+
bytes=more-and-more
|
113
|
+
).each do | garbage |
|
114
|
+
expect {
|
115
|
+
described_class.parse(garbage, 10000)
|
116
|
+
}.to raise_error(described_class::InvalidRange)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: range_header_parser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Julik Tarkhanov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: range_utils
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rdoc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: jeweler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.0.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.0.1
|
83
|
+
description: Parses Range HTTP headers for specific fetches
|
84
|
+
email: me@julik.nl
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files:
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
90
|
+
files:
|
91
|
+
- ".travis.yml"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- authorization_header_parser.gemspec
|
97
|
+
- lib/range_header_parser.rb
|
98
|
+
- lib/range_header_parser/version.rb
|
99
|
+
- range_header_parser.gemspec
|
100
|
+
- spec/range_header_parser_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
homepage: http://github.com/wetransfer/range_header_parser
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.2.2
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: with range splicing and proper offsets
|
126
|
+
test_files: []
|