gipadm
gipadm

Reputation: 543

Google App Engine (PHP) Response too large

When using the get_headers() php function in a deployed app, e.g.:

$aHeaders = get_headers("http://[...].mp3", 1);
echo $aHeaders['Content-Length'];

I get the following error:

PHP Warning: get_headers(http://[...].mp3): failed to open stream: Response too large in /base/data/home/apps/[...]/main.php

The error doesn't appear when the file is small (e.g. 100kb).

I need to get the size of a file on an external server without having to download it. Also, I can't use curl as it is not supported by GAE. Any ideas?

Upvotes: 0

Views: 355

Answers (1)

M. Foti
M. Foti

Reputation: 3182

do you try to do an HEAD request instead of a GET (that downloads all content)?

stream_context_set_default(
    array(
        'http' => array(
            'method' => 'HEAD'
        )
    )
);
$headers = get_headers('http://[...].mp3', 1);

Upvotes: 3

Related Questions