You are here

private function StreamHandler::add_debug in Lockr 7.3

File

vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php, line 473

Class

StreamHandler
HTTP handler that uses PHP's HTTP stream wrapper.

Namespace

GuzzleHttp\Handler

Code

private function add_debug(RequestInterface $request, &$options, $value, &$params) {
  if ($value === false) {
    return;
  }
  static $map = [
    STREAM_NOTIFY_CONNECT => 'CONNECT',
    STREAM_NOTIFY_AUTH_REQUIRED => 'AUTH_REQUIRED',
    STREAM_NOTIFY_AUTH_RESULT => 'AUTH_RESULT',
    STREAM_NOTIFY_MIME_TYPE_IS => 'MIME_TYPE_IS',
    STREAM_NOTIFY_FILE_SIZE_IS => 'FILE_SIZE_IS',
    STREAM_NOTIFY_REDIRECTED => 'REDIRECTED',
    STREAM_NOTIFY_PROGRESS => 'PROGRESS',
    STREAM_NOTIFY_FAILURE => 'FAILURE',
    STREAM_NOTIFY_COMPLETED => 'COMPLETED',
    STREAM_NOTIFY_RESOLVE => 'RESOLVE',
  ];
  static $args = [
    'severity',
    'message',
    'message_code',
    'bytes_transferred',
    'bytes_max',
  ];
  $value = \GuzzleHttp\debug_resource($value);
  $ident = $request
    ->getMethod() . ' ' . $request
    ->getUri()
    ->withFragment('');
  $this
    ->addNotification($params, function () use ($ident, $value, $map, $args) {
    $passed = func_get_args();
    $code = array_shift($passed);
    fprintf($value, '<%s> [%s] ', $ident, $map[$code]);
    foreach (array_filter($passed) as $i => $v) {
      fwrite($value, $args[$i] . ': "' . $v . '" ');
    }
    fwrite($value, "\n");
  });
}