<commit_before>module EPP
  # A server error
  class ServerError < RuntimeError; end

  # Handles sending and receiving data to EPP servers.
  # Supports new style EPP servers which include length of payloads in transmission.
  class Server

    # Default Service URNs
    DEFAULT_SERVICES = %w(urn:ietf:params:xml:ns:domain-1.0
      urn:ietf:params:xml:ns:contact-1.0 urn:ietf:params:xml:ns:host-1.0)

    # Default connection options
    DEFAULTS = { :port => 700, :compatibility => false, :lang => 'en', :version => '1.0',
      :extensions => [], :services => DEFAULT_SERVICES }

    # Receive frame header length
    # @private
    HEADER_LEN = 4

    # @param [String] tag EPP Tag
    # @param [String] passwd EPP Tag password
    # @param [String] host EPP Server address
    # @param [Hash] options configuration options
    # @option options [Integer] :port EPP Port number, default 700
    # @option options [Boolean] :compatibility Compatibility mode, default false
    # @option options [String] :lang EPP Language code, default 'en'
    # @option options [String] :version EPP protocol version, default '1.0'
    # @option options [Array<String>] :extensions EPP Extension URNs
    # @option options [Array<String>] :services EPP Service URNs
    def initialize(tag, passwd, host, options = {})
      @tag, @passwd, @host = tag, passwd, host
      @options = DEFAULTS.merge(options)
    end

    # Sends a Hello Request to the server
    # @return [Boolean] True if greeting was returned
    def hello
      send_frame(HelloRequest.new.to_s)
      return true if recv_frame =~ /<greeting>/
      false
    end

    # Send request to server
    #
    # @overload request(command, payload)
    #   @param [String, #to_s] command EPP Command to call
    #   @param [XML::Node, XML::Document, String] payload EPP XML Payload
    # @overload request(command)
    #   @param [String, #to_s] command EPP Command to call
    #   @yield [xml] block to construct payload
    #   @yieldparam [XML::Node] xml XML Node of the command
    #     for the payload to be added into
    # @return [Response] EPP Response object
    def request(command, payload = nil, &block)
      req = if payload.nil? && block_given?
        Request.new(command, next_tid, &block)
      else
        Request.new(command, payload, next_tid)
      end

      send_recv_frame(req.to_s)
    end

    # Runs a block while logged into the receiver
    #
    # @yield logged in EPP server session
    # @example typical usage
    #   with_login do
    #     # .. do stuff with logged in session ..
    #   end
    def with_login
      login!
<commit_msg>Cache request and response in instance variables<commit_after>module EPP
  # A server error
  class ServerError < RuntimeError; end

  # Handles sending and receiving data to EPP servers.
  # Supports new style EPP servers which include length of payloads in transmission.
  class Server

    # Default Service URNs
    DEFAULT_SERVICES = %w(urn:ietf:params:xml:ns:domain-1.0
      urn:ietf:params:xml:ns:contact-1.0 urn:ietf:params:xml:ns:host-1.0)

    # Default connection options
    DEFAULTS = { :port => 700, :compatibility => false, :lang => 'en', :version => '1.0',
      :extensions => [], :services => DEFAULT_SERVICES }

    # Receive frame header length
    # @private
    HEADER_LEN = 4

    # @param [String] tag EPP Tag
    # @param [String] passwd EPP Tag password
    # @param [String] host EPP Server address
    # @param [Hash] options configuration options
    # @option options [Integer] :port EPP Port number, default 700
    # @option options [Boolean] :compatibility Compatibility mode, default false
    # @option options [String] :lang EPP Language code, default 'en'
    # @option options [String] :version EPP protocol version, default '1.0'
    # @option options [Array<String>] :extensions EPP Extension URNs
    # @option options [Array<String>] :services EPP Service URNs
    def initialize(tag, passwd, host, options = {})
      @tag, @passwd, @host = tag, passwd, host
      @options = DEFAULTS.merge(options)
    end

    # Sends a Hello Request to the server
    # @return [Boolean] True if greeting was returned
    def hello
      send_frame(HelloRequest.new.to_s)
      return true if recv_frame =~ /<greeting>/
      false
    end

    # Send request to server
    #
    # @overload request(command, payload)
    #   @param [String, #to_s] command EPP Command to call
    #   @param [XML::Node, XML::Document, String] payload EPP XML Payload
    # @overload request(command)
    #   @param [String, #to_s] command EPP Command to call
    #   @yield [xml] block to construct payload
    #   @yieldparam [XML::Node] xml XML Node of the command
    #     for the payload to be added into
    # @return [Response] EPP Response object
    def request(command, payload = nil, &block)
      @req = if payload.nil? && block_given?
        Request.new(command, next_tid, &block)
      else
        Request.new(command, payload, next_tid)
      end

      @resp = send_recv_frame(@req.to_s)
    end

    # Runs a block while logged into the receiver
    #
    # @yield logged in EPP server session
    # @example typical usage
    #   with_login do
    #     # .. do stuff with logged in session ..
    #   end
    def with_login
      login!

{'fraction_non_alphanumeric': 0.09809469911337483, 'fraction_numerical': 0.006413884172797585, 'mean_word_length': 2.9596713965646004, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '205141', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1580, 'n_words': 559}