Ejemplo
rack 3.2.7: Fix Rack 3 rejecting response headers after an upgrade, when the app works fine on its own
Muestra verificada para gem rack 3.2.7: Fix Rack 3 rejecting response headers after an upgrade, when the app works fine on its own. El contrato se ejecutó en…
sha256:38abb501510fb17bfdb930c07ec29721747faa1966dbcfabff85019f9c5bcf1d
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 2
- Claves de firma que lo compilaron
- 2
Entorno declarado
ruby 3 linux x64 ruby 3 ruby bundler
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| ruby 3 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · gem@1 |
2026-08-14 |
| ruby 3 · linux debian/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · gem@1 |
2026-08-17 |
Caso
MIGRATION- Objetivo
- Fix Rack 3 rejecting response headers after an upgrade, when the app works fine on its own
- Paquetes
- Símbolos
-
- Rack::Lint
- Rack::Response
- Rack::Headers
- Entorno
- ruby 3
- Creado
- 2026-08-14T06:09:27Z
Contrato
- assert an app returning an uppercase header name still returns 200 on its own
- assert Rack::Lint raises LintError on the uppercase name
- assert Rack::Response stores the key lowercase whatever case was written
- assert Rack::Utils::HeaderHash no longer exists
Archivos
- Gemfile
- Gemfile.lock
- csx.json
- test/contract.rb
Código fuente
source "https://rubygems.org"
gem "rack", "3.2.7"
gem "minitest", "5.25.4"
GEM
remote: https://rubygems.org/
specs:
minitest (5.25.4)
rack (3.2.7)
PLATFORMS
ruby
x86_64-linux-musl
DEPENDENCIES
minitest (= 5.25.4)
rack (= 3.2.7)
CHECKSUMS
bundler (4.0.18) sha256=02d9a17429de1847b4e0c9f27a9ee4b20c0a74c0a641b4e77195d6019e3618ac
minitest (5.25.4) sha256=9cf2cae25ac4dfc90c988ebc3b917f53c054978b673273da1bd20bcb0778f947
rack (3.2.7) sha256=93e13e1c24f93556671d85d2d79fa228c3485815c50d7e2f265b5330c6528fb7
BUNDLED WITH
4.0.18
{"case":{"caseId":"case:sha256:2c858b4ff43d71c72cdecf7c4763515d39133b174933c0c860fde223ecf16853","constraints":{"runtime":"ruby"},"contract":["assert an app returning an uppercase header name still returns 200 on its own","assert Rack::Lint raises LintError on the uppercase name","assert Rack::Response stores the key lowercase whatever case was written","assert Rack::Utils::HeaderHash no longer exists"],"goal":"Fix Rack 3 rejecting response headers after an upgrade, when the app works fine on its own","kind":"MIGRATION","packages":["pkg:gem/rack@3.2.7"],"schemaVersion":1,"symbols":["Rack::Lint","Rack::Response","Rack::Headers"]},"contractCommand":["bundle","exec","ruby","test/contract.rb"],"environment":{"arch":"x64","ecosystem":"gem","executionContext":"ruby","language":"ruby","os":"linux","packageManager":"bundler","runtime":"ruby","runtimeVersion":"3","schemaVersion":1},"license":"MIT-0","packages":["pkg:gem/rack@3.2.7"],"schemaVersion":1,"symbols":["Rack::Lint","Rack::Response","Rack::Headers"],"verifierAdapter":"gem@1"}
require "minitest/autorun"
require "rack"
require "rack/lint"
# Rack 3 requires response header names to be lowercase. The catch is where
# the failure shows up: a bare app returning "Content-Type" works perfectly
# well on its own, and only a server or middleware that lints the response
# rejects it. So the upgrade passes in a unit test and fails in production.
class Rack3HeaderTest < Minitest::Test
UPPERCASE = ->(_env) { [200, { "Content-Type" => "text/plain" }, ["ok"]] }
LOWERCASE = ->(_env) { [200, { "content-type" => "text/plain" }, ["ok"]] }
def env
Rack::MockRequest.env_for("http://example.com/")
end
def test_the_app_itself_does_not_complain
assert_equal 200, UPPERCASE.call(env).first
end
def test_but_lint_rejects_the_uppercase_name
err = assert_raises(Rack::Lint::LintError) { Rack::Lint.new(UPPERCASE).call(env) }
assert_match(/uppercase character in header name/, err.message)
end
def test_lowercase_passes_lint
assert_equal 200, Rack::Lint.new(LOWERCASE).call(env).first
end
def test_rack_response_downcases_for_you
# The fix that scales: build the response through Rack::Response and the
# key is stored lowercase whatever case you wrote.
res = Rack::Response.new
res["Content-Type"] = "text/plain"
assert_equal ["content-type"], res.headers.keys
end
def test_headers_lookup_is_case_insensitive
h = Rack::Headers.new
h["Content-Type"] = "text/plain"
assert_equal "text/plain", h["content-type"]
assert_equal ["content-type"], h.keys
end
def test_the_rack2_header_hash_is_gone
# Rack::Utils::HeaderHash was the Rack 2 way to do this and referencing
# it is a NameError now, not a deprecation.
refute defined?(Rack::Utils::HeaderHash)
end
end