无需在Google应用引擎(php)中下载即可获取远程网址的文件大小

Hi want to check the file size of some remote file size , below csize function working normally in localhost.But when i hosted in google app engine i came to know there is not curl support.so i used purl wrapper.Still i am facing error.

I heard its possible to use java inside gae php file..if so is there any function in java to get file size of remote file ? If so how to use it inside php.

<?php

require_once 'Purl.php';


echo csize('http://www.example.com');


function csize($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
return $size;
}

Just use http streams API

function csize($url) {
  $options = ['http' => [
      'method' => 'HEAD',
    ],
  ];
  $ctx = stream_context_create($options);
  $result = file_get_contents($url, false, $ctx);
  if ($result !== false) {
    foreach($http_response_header as $header) {
      if (preg_match("/Content-Length: (\d+)/i", $header, $matches)) {
        return $matches[1];
      }
    }
  }
}