From: Tom Hughes Date: Fri, 11 Apr 2025 23:09:27 +0000 (+0100) Subject: Pass correct headers to requests X-Git-Tag: live~29^2~2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/ca3b7fd3bbbb3270ca0d5fc7999f66db47ff0f85?ds=sidebyside Pass correct headers to requests Let rack convert to the internal names instead of using them directly and bypassing some of the internals. --- diff --git a/test/integration/compressed_requests_test.rb b/test/integration/compressed_requests_test.rb index 3f6f13cc9..372d2dfe1 100644 --- a/test/integration/compressed_requests_test.rb +++ b/test/integration/compressed_requests_test.rb @@ -38,7 +38,7 @@ class CompressedRequestsTest < ActionDispatch::IntegrationTest post "/api/0.6/changeset/#{changeset.id}/upload", :params => diff, :headers => bearer_authorization_header(user).merge( - "HTTP_CONTENT_TYPE" => "application/xml" + "Content-Type" => "application/xml" ) assert_response :success, "can't upload an uncompressed diff to changeset: #{@response.body}" @@ -86,8 +86,8 @@ class CompressedRequestsTest < ActionDispatch::IntegrationTest post "/api/0.6/changeset/#{changeset.id}/upload", :params => gzip_content(diff), :headers => bearer_authorization_header(user).merge( - "HTTP_CONTENT_ENCODING" => "gzip", - "HTTP_CONTENT_TYPE" => "application/xml" + "Content-Encoding" => "gzip", + "Content-Type" => "application/xml" ) assert_response :success, "can't upload a gzip compressed diff to changeset: #{@response.body}" @@ -135,8 +135,8 @@ class CompressedRequestsTest < ActionDispatch::IntegrationTest post "/api/0.6/changeset/#{changeset.id}/upload", :params => deflate_content(diff), :headers => bearer_authorization_header(user).merge( - "HTTP_CONTENT_ENCODING" => "deflate", - "HTTP_CONTENT_TYPE" => "application/xml" + "Content-Encoding" => "deflate", + "Content-Type" => "application/xml" ) assert_response :success, "can't upload a deflate compressed diff to changeset: #{@response.body}" @@ -155,8 +155,8 @@ class CompressedRequestsTest < ActionDispatch::IntegrationTest post "/api/0.6/changeset/#{changeset.id}/upload", :params => "", :headers => bearer_authorization_header(user).merge( - "HTTP_CONTENT_ENCODING" => "unknown", - "HTTP_CONTENT_TYPE" => "application/xml" + "Content-Encoding" => "unknown", + "Content-Type" => "application/xml" ) assert_response :unsupported_media_type end diff --git a/test/integration/cors_test.rb b/test/integration/cors_test.rb index c35f73d34..88201231b 100644 --- a/test/integration/cors_test.rb +++ b/test/integration/cors_test.rb @@ -3,8 +3,8 @@ require "test_helper" class CORSTest < ActionDispatch::IntegrationTest def test_api_routes_allow_cross_origin_requests process :options, "/api/capabilities", :headers => { - "HTTP_ORIGIN" => "http://www.example.com", - "HTTP_ACCESS_CONTROL_REQUEST_METHOD" => "GET" + "Origin" => "http://www.example.com", + "Access-Control-Request-Method" => "GET" } assert_response :success @@ -15,8 +15,8 @@ class CORSTest < ActionDispatch::IntegrationTest def test_non_api_routes_dont_allow_cross_origin_requests process :options, "/", :headers => { - "HTTP_ORIGIN" => "http://www.example.com", - "HTTP_ACCESS_CONTROL_REQUEST_METHOD" => "GET" + "Origin" => "http://www.example.com", + "Access-Control-Request-Method" => "GET" } assert_response :success diff --git a/test/integration/page_locale_test.rb b/test/integration/page_locale_test.rb index 6f6d7779f..b2f782d30 100644 --- a/test/integration/page_locale_test.rb +++ b/test/integration/page_locale_test.rb @@ -14,7 +14,7 @@ class PageLocaleTest < ActionDispatch::IntegrationTest assert_empty User.find(user.id).languages assert_select "html[lang=?]", "en" - get "/diary/new", :headers => { "HTTP_ACCEPT_LANGUAGE" => "fr, en" } + get "/diary/new", :headers => { "Accept-Language" => "fr, en" } assert_equal %w[fr en], User.find(user.id).languages assert_select "html[lang=?]", "fr" end