namespace PhpXmlRpc;
-use PhpXmlRpc\Helper\XMLParser;
+use PhpXmlRpc\Helper\Logger;
use PhpXmlRpc\Helper\Charset;
+use PhpXmlRpc\Helper\XMLParser;
/**
* Allows effortless implementation of XML-RPC servers
}
/**
- * Add a string to the debug info that can be later serialized by the server
- * as part of the response message.
- * Note that for best compatibility, the debug string should be encoded using
- * the PhpXmlRpc::$xmlrpc_internalencoding character set.
+ * Add a string to the debug info that can be later serialized by the server as part of the response message.
+ * Note that for best compatibility, the debug string should be encoded using the PhpXmlRpc::$xmlrpc_internalencoding
+ * character set.
*
* @param string $msg
* @access public
}
}
- // do not output content-length header if php is compressing output for us:
- // it will mess up measurements
+ // Do not output content-length header if php is compressing output for us:
+ // it will mess up measurements.
+ // Note that Apache/mod_php will add (and even alter!) the Content-Length header on its own, but only for
+ // responses up to 8000 bytes
if ($phpNoSelfCompress) {
header('Content-Length: ' . (int)strlen($payload));
}
} else {
- error_log('XML-RPC: ' . __METHOD__ . ': http headers already sent before response is fully generated. Check for php warning or error messages');
+ Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': http headers already sent before response is fully generated. Check for php warning or error messages');
}
print $payload;
// check if $_SERVER is populated: it might have been disabled via ini file
// (this is true even when in CLI mode)
if (count($_SERVER) == 0) {
- error_log('XML-RPC: ' . __METHOD__ . ': cannot parse request headers as $_SERVER is not populated');
+ Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': cannot parse request headers as $_SERVER is not populated');
}
if ($this->debug > 1) {
// decompose incoming XML into request structure
if ($reqEncoding != '') {
- // Since parsing will fail if charset is not specified in the xml prologue,
- // the encoding is not UTF8 and there are non-ascii chars in the text, we try to work round that...
+ // Since parsing will fail if
+ // - charset is not specified in the xml prologue,
+ // - the encoding is not UTF8 and
+ // - there are non-ascii chars in the text,
+ // we try to work round that...
// The following code might be better for mb_string enabled installs, but
// makes the lib about 200% slower...
//if (!is_valid_charset($reqEncoding, array('UTF-8')))
if (extension_loaded('mbstring')) {
$data = mb_convert_encoding($data, 'UTF-8', $reqEncoding);
} else {
- error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $reqEncoding);
+ Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $reqEncoding);
}
}
}
// verify that function to be invoked is in fact callable
if (!is_callable($func)) {
- error_log("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler is not callable");
+ Logger::instance()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler is not callable");
return new Response(
0,
PhpXmlRpc::$xmlrpcerr['server_error'],
$r = call_user_func($func, $req);
}
if (!is_a($r, 'PhpXmlRpc\Response')) {
- error_log("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler does not return an xmlrpc response object but a " . gettype($r));
+ Logger::instance()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler does not return an xmlrpc response object but a " . gettype($r));
if (is_a($r, 'PhpXmlRpc\Value')) {
$r = new Response($r);
} else {
}
}
throw $e;
- break;
case 1:
$r = new Response(0, $e->getCode(), $e->getMessage());
break;
}
if (isset($dmap[$methName])) {
if (isset($dmap[$methName]['docstring'])) {
- $r = new Response(new Value($dmap[$methName]['docstring']), 'string');
+ $r = new Response(new Value($dmap[$methName]['docstring'], 'string'));
} else {
$r = new Response(new Value('', 'string'));
}
// The previous error handler was the default: all we should do is log error
// to the default error log (if level high enough)
if (ini_get('log_errors') && (intval(ini_get('error_reporting')) & $errCode)) {
- error_log($errString);
+ Logger::instance()->errorLog($errString);
}
} else {
// Pass control on to previous error handler, trying to avoid loops...