Created
February 27, 2014 22:04
-
-
Save fancyremarker/9260579 to your computer and use it in GitHub Desktop.
Demonstration of header caching bug in HyperResource
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'sinatra' | |
gem 'hyperresource' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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