def send_request(text)
      params = {
        'text' => text.encode("cp1251"),
      }
      params['xml'] = @xml if @xml
      request = Net::HTTP::Post.new(@url.path)
      request.set_form_data(params)

      begin
        response = Net::HTTP.new(@url.host, @url.port).start do |http|
          http.request(request)
        end
      rescue StandardError => exception
        raise NetworkError.new(exception.message, exception.backtrace)
      end

      if !response.is_a?(Net::HTTPOK)
        raise NetworkError, "#{response.code}: #{response.message}"
      end

      body = response.body.force_encoding("cp1251").encode("utf-8")

      # error = "\xCE\xF8\xE8\xE1\xEA\xE0: \xE2\xFB \xE7\xE0\xE1\xFB\xEB\xE8 \xEF\xE5\xF0\xE5\xE4\xE0\xF2\xFC \xF2\xE5\xEA\xF1\xF2"
      # error.force_encoding("ASCII-8BIT") if error.respond_to?(:force_encoding)
      if body == "Ошибка: вы забыли передать текст"
        raise NetworkError, "Ошибка: вы забыли передать текст"
      end

      if @options[:symbols] == 2
        HTMLEntities.new.decode(body.chomp)
      else
        body.chomp
      end
    end
def send_request(text)
      params = {
        'text' => text.encode("cp1251"),
      }
      params['xml'] = @xml if @xml
      request = Net::HTTP::Post.new(@url.path)
      request.set_form_data(params)

      begin
        response = Net::HTTP.new(@url.host, @url.port).start do |http|
          http.request(request)
        end
      rescue StandardError => exception
        raise NetworkError.new(exception.message, exception.backtrace)
      end

      if !response.is_a?(Net::HTTPOK)
        raise NetworkError, "#{response.code}: #{response.message}"
      end

      body = response.body.force_encoding("cp1251").encode("utf-8")

      # error = "\xCE\xF8\xE8\xE1\xEA\xE0: \xE2\xFB \xE7\xE0\xE1\xFB\xEB\xE8 \xEF\xE5\xF0\xE5\xE4\xE0\xF2\xFC \xF2\xE5\xEA\xF1\xF2"
      # error.force_encoding("ASCII-8BIT") if error.respond_to?(:force_encoding)
      if body == "Ошибка: вы забыли передать текст"
        raise NetworkError, "Ошибка: вы забыли передать текст"
      end

      if @options[:symbols] == 2
        HTMLEntities.new.decode(body.chomp)
      else
        body.chomp
      end
    end
Process text with remote web-service