Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9747: send_accept_charset_header_with_basic_auth.2.diff

File send_accept_charset_header_with_basic_auth.2.diff, 1.7 kB (added by norbert, 1 year ago)

How about this?

  • actionpack/test/controller/http_authentication_test.rb

    old new  
    22 
    33class HttpBasicAuthenticationTest < Test::Unit::TestCase 
    44  include ActionController::HttpAuthentication::Basic 
     5 
     6  cattr_accessor :default_charset 
     7  @@default_charset = 'utf-8' 
    58   
    69  class DummyController 
    710    attr_accessor :headers, :renders, :request 
     11 
     12    cattr_accessor :default_charset 
     13    @@default_charset = 'utf-8' 
    814     
    915    def initialize 
    1016      @headers, @renders = {}, [] 
     
    4349   
    4450  def test_authentication_request 
    4551    authentication_request(@controller, "Megaglobalapp") 
     52    assert_equal @controller.class.default_charset, @controller.headers["Accept-Charset"] 
    4653    assert_equal 'Basic realm="Megaglobalapp"', @controller.headers["WWW-Authenticate"] 
    4754    assert_equal :unauthorized, @controller.renders.first[:status] 
    4855  end 
  • actionpack/lib/action_controller/http_authentication.rb

    old new  
    120120      end 
    121121 
    122122      def authentication_request(controller, realm) 
     123        controller.headers["Accept-Charset"] = self.class.default_charset 
    123124        controller.headers["WWW-Authenticate"] = %(Basic realm="#{realm.gsub(/"/, "")}") 
    124125        controller.send! :render, :text => "HTTP Basic: Access denied.\n", :status => :unauthorized 
    125126        return false