Sinatra not passing header with redirect
Posted
by emson
on Stack Overflow
See other posts from Stack Overflow
or by emson
Published on 2010-06-01T14:28:29Z
Indexed on
2010/06/01
14:33 UTC
Read the original article
Hit count: 236
Hi All
I have a simple Sinatra proxy, which when an endpoint is called, will redirect to another endpoint on the same Sinatra proxy.
When I make a request with a header, the proxy doesn't seem to pass this header through to the second endpoint when the request redirects in the first. This is my code:
get '/first' do
# get the header from the request
username = env['HTTP_USERNAME']
# set the header for the response
response['username'] = username
redirect '/second'
end
get '/second' do
# This doesn't exist when redirected from /first
puts env['HTTP_USERNAME']
# Here is a list of all headers
env.each_key do |key|
puts "KEY: #{key} VALUE: #{env[key]}" unless key.nil?
end
"DONE"
end
Any tips would be greatly appreciated.
Thanks
© Stack Overflow or respective owner