cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: setting a max time for http downloads

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 7 Oct 2002 10:46:46 +0200 (MET DST)

On Mon, 7 Oct 2002, Cliff Small wrote:

[original mail posted to curl-users, I reply on curl-and-php instead]

> I would like to set a max time for downloading web content. I've tried the
> following:
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
> curl_setopt($ch, CURLOPT_LOW_SPEED_TIME,3);
> curl_setopt($ch, CURLOPT_URL,"$site_url");
> ob_start();
> curl_exec($ch);
> curl_close($ch);
>
> I'm testing my script for download times using microtime() and continue to
> get file downloads from 6 to 22 seconds. I want the script to skip the
> download if it takes longer than 3 seconds. What am I missing???

You should probably use the plain CURLOPT_TIMEOUT.

The CURLOPT_LOW_SPEED_TIME one is 'the time in seconds that the transfer
should be below the CURLOPT_LOW_SPEED_LIMIT for the library to consider it
too slow and abort'. So normally, if you use the LOW_SPEED_TIME you should
also use the LOW_SPEED_LIMIT to make it actually do what you want. To set a
general timeout option, those are not the right options though.

-- 
 Daniel Stenberg -- curl related mails on curl related mailing lists please
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-10-07