# File lib/www/mechanize/page.rb, line 25
      def initialize(uri=nil, response=nil, body=nil, code=nil, mech=nil)
        @encoding = nil

        method = response.respond_to?(:each_header) ? :each_header : :each
        response.send(method) do |header,v|
          next unless v =~ /charset/i
          encoding = v.split('=').last.strip
          @encoding = encoding unless encoding == 'none'
        end

        # Force the encoding to be 8BIT so we can perform regular expressions.
        # We'll set it to the detected encoding later
        body.force_encoding('ASCII-8BIT') if defined?(Encoding) && body

        @encoding ||= Util.detect_charset(body)

        super(uri, response, body, code)
        @mech           ||= mech

        @encoding = nil if html_body =~ /<meta[^>]*charset[^>]*>/i

        raise Mechanize::ContentTypeError.new(response['content-type']) unless
           response['content-type'] =~ /^(text\/html)|(application\/xhtml\+xml)/i
        @parser = @links = @forms = @meta = @bases = @frames = @iframes = nil
      end