cURL / Mailing Lists / curl-library / Single Mail

curl-library

cURL trying to use the file protocol (when not requested) - intermittent issue

From: Gilad Parann-Nissany <gilad_at_parann.net>
Date: Thu, 10 Sep 2009 23:26:25 +0300

Hi

I've searched for many hours on this issue with no answer, so hopefully this
mailing list's experts will know the answer.

While some of the issue is PHP related, it also has internal libcurl aspects
- that is the part I am concerned about - which is why I am asking this
mailing list.

I am using the following options to make an HTTP call

                    CURLOPT_PUT => true,
                    CURLOPT_INFILESIZE => content_length,
                    CURLOPT_READFUNCTION => 'mycallback'

(other options truncated for brevity)

This PUTs a file and the request body is processed through the 'mycallback'
function. This works fine *most of the time* but not all the time.

If the data is large > 100K, and even then only SOME of the time
(intermittently), I get a message:

CURLPROTO_FILE cannot be activated when in safe_mode or an open_basedir is
set

Now I completely understand the PHP part of this message: I have set in PHP
"open_basedir" to limit the directories that my code can use; this is a
deliberate security measure to make life hard for hackers so they cannot
access just anywhere on the disk. So that is *not *my question.

However this implies that some of the time (intermittently) the libcurl code
tries to create some kind of file on my disk; maybe a temp file to cache the
data I am streaming? And then it hits my deliberate security limitation.

I have not asked it to do so - the 'callback' is actually *implementing a
streaming approach* and so all the request is supposed to be in memory. I
chose streaming like this to avoid needing too much memory and to avoid the
overhead of reading/writing anything to disk.

So I am a bit concerned that cURL seems to be writing/reading to disk under
the hood. I suspect CURL is doing so because obviously CURLPROTO_FILE is the
curl file protocol and - as I said - I am only using HTTP !!

My questions:

1. am I correct in the analysis - does libcurl indeed have code that might
write buffers to the disk sometimes (but not all the time) when using the
callback mechanism?
2. can you explain the conditions where this may happen and why?
3. is there any way to configure cURL to control this behavior?

I am working with PHP 5.2.10 and libcurl 7.19.4 in Apache 2.2.11 on Win32
(XP).

Apologies in advance if I misunderstood the situation - and thanks in
advance for any help.

Regards
Gilad
__________________
Gilad Parann-Nissany
Received on 2009-09-10