# File lib/casclient/responses.rb, line 144
    def parse_http_response(http_response)
      header = http_response.to_hash
      
      # FIXME: this regexp might be incorrect...
      if header['set-cookie'] && 
          header['set-cookie'].first && 
          header['set-cookie'].first =~ /tgt=([^&]+);/
        @tgt = $~[1]
      end
    
      location = header['location'].first if header['location'] && header['location'].first
      if location =~ /ticket=([^&]+)/
        @ticket = $~[1]
      end
      
      if !http_response.kind_of?(Net::HTTPSuccess) || ticket.blank?
        @failure = true
        # Try to extract the error message -- this only works with RubyCAS-Server.
        # For other servers we just return the entire response body (i.e. the whole error page).
        body = http_response.body
        if body =~ /<div class="messagebox mistake">(.*?)<\/div>/m
          @failure_message = $~[1].strip
        else
          @failure_message = body
        end
      end
      
      @service_redirect_url = location
    end