function getLastRequestQuery($stripEnvelope = false)
  {
    $html = $this->_lastRequestQuery;

    if (php_sapi_name() == 'cli') {
      // remove user/password
      if (!$this->_debug) {
        $html = preg_replace(array("<\<cps:user\>(.*)\<\/cps:user\>>", "<\<cps:password\>(.*)\<\/cps:password\>>"),
          array('<cps:user>CPS_USER</cps:user>', '<cps:password>CPS_PASSWORD</cps:password>'), $this->_lastRequestQuery);
      }

      // remove everything except cps:content
      if ($stripEnvelope) {
        preg_match("<\<cps:content\>([\s\S.]*)\<\/cps:content\>>",
          $html, $matches);
        $html = @$matches[1];
      }

      return "Sent:\n" . $html . '\n';
    } else {
      // try to pretty format
      try {
        $doc = new DOMDocument();
        $doc->strictErrorChecking = false;
        $doc->preserveWhiteSpace = false;
        $doc->formatOutput = true;
        @$doc->loadXML($this->_lastRequestQuery);
        $html = $doc->saveXML();
      } catch (Exception $e) {
        // do nothing
      }

      // remove user/password
      if (!$this->_debug) {
        $html = preg_replace(array("<\<cps:user\>(.*)\<\/cps:user\>>", "<\<cps:password\>(.*)\<\/cps:password\>>"),
          array('<cps:user>CPS_USER</cps:user>', '<cps:password>CPS_PASSWORD</cps:password>'), $html);
      }

      // remove everything except cps:content
      if ($stripEnvelope) {
        preg_match("<\<cps:content\>([\s\S.]*)\<\/cps:content\>>",
          $html, $matches);
        $html = @$matches[1];
      }

      return 'Sent: <br /><pre>' . htmlspecialchars($html) . '</pre>';
    }
  }