curl-users
Re: Download head of file
Date: Mon, 04 Sep 2006 07:06:16 +0300
Dan Fandrich wrote:
> On Sun, Sep 03, 2006 at 09:09:18PM +0300, Oleg Lomaka wrote:
>
>> I develop a service where users enter an url and script should download
>> this page to process. But one may enter the url of huge file I don't
>> want to download. But it is need to view first few kbytes.
>>
>
> How about: curl http://example.com | head -c 2048 ?
>
I've tried this. But in this case curl will stop transfer not after 2048
bytes will be received, but when pipe will be closed and it can't write
there next part of data. For example when i use --max-hard-filesize,
curl gets 2353 bytes, using head - 4111.
home% ./curl --max-hard-filesize 2048
"http://www.google.com/search?q=something" > /dev/null
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
56 4111 56 2353 0 0 722 0 0:00:05 0:00:03
0:00:02 2574
curl: (23) Failed writing body
home% ./curl "http://www.google.com/search?q=something" | head -c 2048 >
/dev/null
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 4111 100 4111 0 0 1484 0 0:00:02 0:00:02
--:--:-- 5151
Anyway thanks for advice.
-- Oleg Lomaka, oleg.lomaka at gmail dot com, ALEK-RIPE, ALEK-UANICReceived on 2006-09-04