Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top