Reputation: 389
I'm using Heroku (heroku.com) to deploy my rails application, and am building an iPhone client to interface with it. My intention was to pass the unique device identifier of the phone to the app as a HTTP header for authentication. When I test locally, my headers come through fine, but on Heroku it seems to strip out my custom header. I verified with a ruby script:
url = URI.parse('http://#{myapp}.heroku.com/')
#url = URI.parse('http://localhost:3000/')
req = Net::HTTP::Post.new(url.path)
#bogus params
req.set_form_data({'from'=>'2005-01-01', 'to'=>'2005-03-31'}, ';')
#device header
req['HTTP_DEVICE_UDID'] = "XXXXXX"
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
Against my local server, the header is there, but on heroku it is not.
Any ideas?
Thanks,
Jeremy
Upvotes: 5
Views: 4109
Reputation: 1384
I posted about this on Heroku support and finally understood what the existing answer meant.
Try using "X-" instead of "X_". For instance, "X-Sendfile" is the name of an HTTP header, but when this gets passed to Rack, this becomes "X_SENDFILE". After this initial punctuation, I believe the rest of the header will be passed normally, aside from being capitalized.
Since you're using Bamboo, your requests get passed through nginx, which will filter out headers it thinks are malformed.
Cheers, JD
Just thought this could be useful for other newbies like me looking for this.
Upvotes: 2
Reputation: 731
Have you tried passing that as an X- header, i.e. X-HTTP-DEVICE-UDID? Most custom or non-standard HTTP headers are passed as X- headers.
Upvotes: 11