For Rack 3.1 apps, pass through the client value in the Version
header #3576
Open
Description
Describe the bug
We have a Rails API app servicing an iPhone app. iPhones send automatically a Version
header with the current app version and we are collecting and storing that data. With puma 5.6.9 running request.headers["Version"]
would return "HTTP/1.1, 8.1.1"
but when we updated to 6.5.0 it would return just "HTTP/1.1"
breaking our application.
Puma config:
threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
port ENV.fetch("PORT", 3000)
# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
# Specify the PID file. Defaults to tmp/pids/server.pid in development.
# In other environments, only set the PID file if requested.
pidfile ENV["PIDFILE"] if ENV["PIDFILE"]
To Reproduce
Create fresh rails api application
rails new puma-test --api
# modify puma and rack versions as needed for testing
bundle install
rails db:create
Add code to check versions
rails g controller Versions
# in versions_controller.rb
class VersionsController < ApplicationController
def index
render json: { versions: request.headers["Version"] }
end
end
Run it with: rails s
Run a curl request
curl -H 'Content-Type: application/json' -H 'Version: 8.1.1' http://localhost:3000/versions
Expected behavior
EXPECTED (= correctly executes in puma <6)
{"versions":"HTTP/1.1, 8.1.1"}
ACTUAL (puma >= 6)
{"versions":"HTTP/1.1"}
Desktop (please complete the following information):
- OS: Mac, Linux
- Puma Version 5 vs 6