HTTPRange
A library to parse an HTTP Range
header for HTTP APIs with semantics
described in SPEC.
Installation
Add this line to your application's Gemfile:
gem 'http_range'
And then execute:
$ bundle
Or install it yourself as:
$ gem install http_range
Usage
http_range = HTTPRange.parse('Range: id 29f99177-36e9-466c-baef-f855e1ab731e..29f99177-36e9-466c-baef-f855e1ab731e[; max=100')
http_range.attribute
http_range.first
http_range.last
http_range.max
http_range.order
http_range.first_inclusive
http_range.last_inclusive
Or, in a Rack app:
app = Rack::Builder.app do
use HTTPRange::Middleware::AcceptRanges
run lambda do |env|
env['rack.range.attribute']
env['rack.range.first']
env['rack.range.last']
env['rack.range.first_inclusive']
env['rack.range.last_inclusive']
env['rack.range.order']
env['rack.range.max']
[200, {}, "Body"]
end
end
Inspiration
Inspired by Heroku's Interagent HTTP API Design as well as brandur's
HTTPAccept library.
Contributing
- Fork it ( https://github.com/h3h/http_range/fork )
- Create your feature branch (
git checkout -b my-new-feature
)
- Commit your changes (
git commit -am 'Add some feature'
)
- Push to the branch (
git push origin my-new-feature
)
- Create a new Pull Request