protected function inspect($id, $options) { $options[CURLOPT_CUSTOMREQUEST] = 'HEAD'; $options[CURLOPT_HEADER] = 1; $options[CURLOPT_NOBODY] = 1; curl_setopt_array($id, $options); $header = curl_exec($id); $body = ''; $res = Net_HTTP_Response::from_string($body, $header); $len = (int) $res->headers['Content-Length']; if ($len > 0) { $limit = $this->get_memory_limit(); if ($limit <= 0) { return; } $allowed_memory = $limit - memory_get_usage(); if (2.1 * $len >= $allowed_memory) { throw new RuntimeException('HTTPAgent: not enough memory to download'); } } }