# File lib/em-twitter/connection.rb, line 148
      def on_headers_complete(headers)
        @response_code  = @parser.status_code
        @headers        = headers

        @decoder = BaseDecoder.new

        # TODO: Complete gzip support
        # detect gzip encoding and use a decoder for response bodies
        # gzip needs to be detected with the Content-Encoding header
        # @decoder = if gzip?
        #   GzipDecoder.new
        # else
        #   BaseDecoder.new
        # end

        # everything below here is error handling so return if we got a 200
        if @response_code.to_i == 200
          @network_reconnector.reset
          @application_reconnector.reset
          return
        end

        # since we got a response use the application failure reconnector
        # to handle reconnects
        @reconnector = @application_reconnector

        case @response_code
        when 401 then invoke_callback(@client.unauthorized_callback)
        when 403 then invoke_callback(@client.forbidden_callback)
        when 404 then invoke_callback(@client.not_found_callback)
        when 406 then invoke_callback(@client.not_acceptable_callback)
        when 413 then invoke_callback(@client.too_long_callback)
        when 416 then invoke_callback(@client.range_unacceptable_callback)
        when 420 then invoke_callback(@client.enhance_your_calm_callback)
        when 503 then invoke_callback(@client.service_unavailable_callback)
        else
          msg = "Unhandled status code: #{@response_code}."
          invoke_callback(@client.error_callback, msg)
        end
      end