# File lib/em-http/client.rb, line 404
    def unbind
      if (@state == :finished) && (@last_effective_url != @uri) && (@redirects < @options[:redirects])
        # update uri to redirect location if we're allowed to traverse deeper
        @uri = @last_effective_url

        # keep track of the depth of requests we made in this session
        @redirects += 1

        # swap current connection and reassign current handler
        req = HttpOptions.new(@method, @uri, @options)
        reconnect(req.host, req.port)

        @response_header = HttpResponseHeader.new
        @state = :response_header
        @response = ''
        @data.clear
      else
        if @state == :finished || (@state == :body && @bytes_remaining.nil?)
          succeed(self)
        else
          @disconnect.call(self) if @state == :websocket and @disconnect
          fail(self)
        end
      end
    end