Forum Moderators: coopster

Message Too Old, No Replies

CURL_setopt options

filesize

         

brotherhood of LAN

10:52 am on Jan 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I've scanned through the list of options curl has to offer within PHP, and can't see one that limits the actual size of a download.

I'm looking to limit the size of downloaded files to 100 kilobytes.

A quick look at the curl.exe flag options brings this option:
-r/--range <range> Retrieve a byte range from a HTTP/1.1 or FTP server

Which I suppose could be used, but isn't supported by all servers.

Is there an option to limit the size of the download, or some kind of work around?

Cheers

// There's also mentionings of "CURLOPT_MAXFILESIZE" on some forum pages but it doesn't seem to be a valid option (at least with my version of php/curl)

jatar_k

7:10 pm on Jan 24, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



is this an option? Patch for CURLOPT_MAXFILESIZE [curl.haxx.se]

brotherhood of LAN

5:18 pm on Feb 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Cheers Jatar

I had a read of how it works, it seems to depend on the existence of a Content-Length header in the HTTP response, which isn't always there.

CURLOPT_RANGE

"Range(s) of data to retrieve in the format "X-Y" where X or Y are optional. HTTP transfers also support several intervals, separated with commas in the format "X-Y,N-M"."

I might try this...I may be wrong but this could also be dependent on the server, if I remember right some servers do not accept byte range requests. I'll just have to toy around with it and see what works.

Any request made to this CURL function of mine has seven seconds to get fetched, so hopefully someone can't user submit a 2 gig file "for the fun of it" :)

The ideal scenario is to limit fetches to 100KB

Cheers