private function headObject($object_name) {
    $headers = $this->getOAuthTokenHeader(parent::READ_SCOPE);
    if ($headers === false) {
      if (!$this->quiet) {
        trigger_error("Unable to acquire OAuth token.", E_USER_WARNING);
      }
      return false;
    }

    $url = $this->createObjectUrl($this->bucket_name, $object_name);
    $http_response = $this->makeHttpRequest($url, "HEAD", $headers);
    if ($http_response === false) {
      if (!$this->quiet) {
        trigger_error('Unable to connect to the Cloud Storage Service.',
                      E_USER_WARNING);
      }
      return false;
    }

    $status_code = $http_response['status_code'];
    if (HttpResponse::OK !== $status_code) {
      if (!$this->quiet && HttpResponse::NOT_FOUND !== $status_code) {
        trigger_error($this->getErrorMessage($http_response['status_code'],
                                             $http_response['body']),
                      E_USER_WARNING);
      }
      return false;
    }

    $headers = $http_response['headers'];
    return ['size' => $this->getHeaderValue('x-goog-stored-content-length',
                                            $headers),
            'mtime' => $this->getHeaderValue('Last-Modified', $headers)];
  }
private function headObject($object_name) {
    $headers = $this->getOAuthTokenHeader(parent::READ_SCOPE);
    if ($headers === false) {
      if (!$this->quiet) {
        trigger_error("Unable to acquire OAuth token.", E_USER_WARNING);
      }
      return false;
    }

    $url = $this->createObjectUrl($this->bucket_name, $object_name);
    $http_response = $this->makeHttpRequest($url, "HEAD", $headers);
    if ($http_response === false) {
      if (!$this->quiet) {
        trigger_error('Unable to connect to the Cloud Storage Service.',
                      E_USER_WARNING);
      }
      return false;
    }

    $status_code = $http_response['status_code'];
    if (HttpResponse::OK !== $status_code) {
      if (!$this->quiet && HttpResponse::NOT_FOUND !== $status_code) {
        trigger_error($this->getErrorMessage($http_response['status_code'],
                                             $http_response['body']),
                      E_USER_WARNING);
      }
      return false;
    }

    $headers = $http_response['headers'];
    return ['size' => $this->getHeaderValue('x-goog-stored-content-length',
                                            $headers),
            'mtime' => $this->getHeaderValue('Last-Modified', $headers)];
  }
private function headObject ( $ object_name ) { $ headers = $ this -> getOAuthTokenHeader ( parent :: READ_SCOPE ) ; if ( $ headers === false ) { if ( ! $ this -> quiet ) { trigger_error ( "Unable to acquire OAuth token." , E_USER_WARNING ) ; } return false ; } $ url = $ this -> createObjectUrl ( $ this -> bucket_name , $ object_name ) ; $ http_response = $ this -> makeHttpRequest ( $ url , "HEAD" , $ headers ) ; if ( $ http_response === false ) { if ( ! $ this -> quiet ) { trigger_error ( 'Unable to connect to the Cloud Storage Service.' , E_USER_WARNING ) ; } return false ; } $ status_code = $ http_response [ 'status_code' ] ; if ( HttpResponse :: OK !== $ status_code ) { if ( ! $ this -> quiet && HttpResponse :: NOT_FOUND !== $ status_code ) { trigger_error ( $ this -> getErrorMessage ( $ http_response [ 'status_code' ] , $ http_response [ 'body' ] ) , E_USER_WARNING ) ; } return false ; } $ headers = $ http_response [ 'headers' ] ; return [ 'size' => $ this -> getHeaderValue ( 'x-goog-stored-content-length' , $ headers ) , 'mtime' => $ this -> getHeaderValue ( 'Last-Modified' , $ headers ) ] ; }
Perform a HEAD request on an object to get size & mtime info.
Perform a HEAD request on an object to get size & mtime info .