Skip to content

Instantly share code, notes, and snippets.

@fancyremarker
Created February 27, 2014 22:04
Show Gist options
  • Save fancyremarker/9260579 to your computer and use it in GitHub Desktop.
Save fancyremarker/9260579 to your computer and use it in GitHub Desktop.
Demonstration of header caching bug in HyperResource
gem 'sinatra'
gem 'hyperresource'
require 'hyperresource'
hr_bar = HyperResource.new(root: 'http://localhost:4000', headers: { 'FOO' => 'bar' })
hr_bar.name
# => "bar"
hr_notbar = HyperResource.new(root: 'http://localhost:4000')
hr_notbar.name
# => "bar"
hr_notbar.get.name
# => "notbar"
require 'sinatra'
require 'json'
set :port, 4000
before do
content_type 'application/hal+json'
end
get '/' do
if request.env['HTTP_FOO'] == 'bar'
name = 'bar'
else
name = 'notbar'
end
{
name: name,
_links: {
self: { href: 'http://localhost:4000/' },
}
}.to_json
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment