Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compliance with Rack : Spec 3. Lower-case HTTP Headers #608

Open
KarenSido opened this issue Feb 12, 2024 · 0 comments
Open

Compliance with Rack : Spec 3. Lower-case HTTP Headers #608

KarenSido opened this issue Feb 12, 2024 · 0 comments

Comments

@KarenSido
Copy link

Hi, I was wondering if rack-mini-profiler intends to be compliant with Rack linter (spec 3), and to HTTP 2 standards, which asks to make HTTP Headers lower-case (although they are "compared in a case-insensitive fashion".. don't ask me why).

Error 500:

Rack::Lint::LintError: uppercase character in header name: Content-Type (Rack::Lint::LintError)
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.9/lib/rack/lint.rb:653:in `block in check_headers'
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.9/lib/rack/lint.rb:637:in `each'
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.9/lib/rack/lint.rb:637:in `check_headers'
	/home/karen/code/lcas/config/initializers/rack_lint_websocket.rb:38:in `check_headers'
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.9/lib/rack/lint.rb:73:in `response'
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.9/lib/rack/lint.rb:35:in `call'
	/home/karen/code/lcas/config/initializers/rack_lint_websocket.rb:9:in `call'
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.9/lib/rack/show_exceptions.rb:27:in `call'
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.9/lib/rack/common_logger.rb:43:in `call'
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.9/lib/rack/content_length.rb:20:in `call'
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/configuration.rb:272:in `call'
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/request.rb:100:in `block in handle_request'
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/thread_pool.rb:378:in `with_force_shutdown'
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/request.rb:99:in `handle_request'
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/server.rb:464:in `process_client'
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/server.rb:245:in `block in run'
	/home/karen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/thread_pool.rb:155:in `block in spawn_thread'
127.0.0.1 - - [12/Feb/2024:09:17:00 +0100] "POST /mini-profiler-resources/results HTTP/1.1" 500 1958 0.012

Am I missing something about rack settings that could disable this rule ? Anyway, it would be nice to make rack mini profiler compliant.
Actually, in order to make rack-mini-profiler to work, I have to patch Rack method check_headers and use Rack Headers class to format rack mini profiler headers (and so all headers from my app, although they are compliant) to avoid this error.

class ::Rack::Lint::Wrapper
    alias check_headers_orig check_headers
    def check_headers(headers)
        headers = Rack::Headers.new(headers)
        
        check_headers_orig(headers)
    end
end

HTTP 2 Standards for lower-case headers:
https://www.rfc-editor.org/rfc/rfc7540#section-8.1.2

Origin issue for lower-case headers of Rack:
rack/rack#1592

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant