Commit 00b6e37e authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-1159 Add maxLength parameter to Request::GetInputAsBase64(), log 10KB

in an WBXML exception case and 4KB in the happy case.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 6c76315d
...@@ -691,12 +691,14 @@ class Request { ...@@ -691,12 +691,14 @@ class Request {
* With POST request (our case), you can open and read * With POST request (our case), you can open and read
* multiple times "php://input" * multiple times "php://input"
* *
* @param int $maxLength max lenght to be returned. Default: return all
*
* @access public * @access public
* @return string - base64 encoded wbxml * @return string - base64 encoded wbxml
*/ */
public static function GetInputAsBase64() { public static function GetInputAsBase64($maxLength = -1) {
$input = fopen('php://input', 'r'); $input = fopen('php://input', 'r');
$wbxml = base64_encode(stream_get_contents($input)); $wbxml = base64_encode(stream_get_contents($input, $maxLength));
fclose($input); fclose($input);
return $wbxml; return $wbxml;
} }
......
...@@ -112,13 +112,15 @@ abstract class RequestProcessor { ...@@ -112,13 +112,15 @@ abstract class RequestProcessor {
} }
} }
catch (Exception $ex) { catch (Exception $ex) {
ZLog::Write(LOGLEVEL_FATAL, "WBXML debug data: " . Request::GetInputAsBase64(), false); // Log 10 KB of the WBXML data
ZLog::Write(LOGLEVEL_FATAL, "WBXML 10K debug data: " . Request::GetInputAsBase64(10240), false);
throw $ex; throw $ex;
} }
// also log WBXML in happy case // also log WBXML in happy case
if (ZLog::IsWbxmlDebugEnabled()) { if (ZLog::IsWbxmlDebugEnabled()) {
ZLog::Write(LOGLEVEL_WBXML, "WBXML-IN : ". Request::GetInputAsBase64(), false); // Log 4 KB in the happy case
ZLog::Write(LOGLEVEL_WBXML, "WBXML-IN : ". Request::GetInputAsBase64(4096), false);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment