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

curl-and-php

RE: retreive partial transfer after timeout

From: <theexperts_at_allprodirect.com>
Date: Sat, 14 Dec 2002 00:21:59 -0500

> I am wondering if writing to a file (i.e. curlopt_file) behaves
> differently, capturing any partial transfer. If so, I could change my php
> program to handle it that way.

It will be different, since I doubt very much that the php/curl module will
remove the file in case of errors (if it even can). I guess it just leaves
it, and that is what libcurl does too.

--
 Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
============================================================
Daniel-
Thanks! You helped me make a breakthrough! It works great!
Now I use output buffering for my problem site, e.g. set a var such as
$bufferoutput = TRUE; Actually, it would probably be just as well to make it
the default/only behavior.
And I don't need to output to a file, STDOUT works fine. This is neater than
having to deal with creating, setting permissions, and deleting files.
In summary: Using this method, whatever has been transferred up to the
timeout gets sent to STDOUT, stored in a buffer, and sent to var $result,
instead of being tossed out like yesterday's coffee grounds as when using
curlopt_returntransfer.
Example code:
------------------------------
.
.
.
    if ($bufferoutput) {
      curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 0);
      ob_start();
      $result = curl_exec ($ch);
      $result = ob_get_contents();
      ob_end_clean();
    }
    else {
      curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
      $result = curl_exec ($ch);
    }
------------------------------
-J.
-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility 
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/
Received on 2002-12-14