<commit_before>module WebSocket
  class ServerHandshake < Http::Response

    def initialize(status = 101, version = "1.1", headers = {}, body = nil, &body_proc)
      @status, @version, @body, @body_proc = status, version, body, body_proc
      @headers = headers
    end

    def render(out)
      response_header = "#{@version} #{@status} #{@reason}#{CRLF}"

      unless @headers.empty?
        response_header << @headers.map do |header, value|
          "#{header}: #{value}"
        end.join(CRLF) << CRLF
      end

      response_header << CRLF

      out << response_header
    end
  end
end<commit_msg>Split data generation and rendering in server handshake<commit_after>module WebSocket
  class ServerHandshake < Http::Response

    def initialize(status = 101, version = "1.1", headers = {}, body = nil, &body_proc)
      @status, @version, @body, @body_proc = status, version, body, body_proc
      @headers = headers
    end

    def render(out)
      out << to_data
    end

    def to_data
      data = "#{@version} #{@status} #{@reason}#{CRLF}"

      unless @headers.empty?
        data << @headers.map do |header, value|
          "#{header}: #{value}"
        end.join(CRLF) << CRLF
      end

      data << CRLF
      data
    end
  end
end
{'fraction_non_alphanumeric': 0.13153724247226625, 'fraction_numerical': 0.00792393026941363, 'mean_word_length': 2.671511627906977, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1764623', 'n_tokens_mistral': 407, 'n_tokens_neox': 386, 'n_words': 110}