Tco UpLoad | 7 Sep 2009 01:00
Picon

change curl listening port

hi.
 If a install site with curl extension over port 80 it work fine.
Otherwise if i change apache2 listen port to 8080 the curl extension
doesn't work any more. so could you help me, to change curl listen
port?

thanks

--

-- 
Ricardo Miguel Ruivo
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

Daniel Stenberg | 7 Sep 2009 08:41
Picon
Favicon
Gravatar

Re: change curl listening port

On Mon, 7 Sep 2009, Tco UpLoad wrote:

> If a install site with curl extension over port 80 it work fine. Otherwise 
> if i change apache2 listen port to 8080 the curl extension doesn't work any 
> more. so could you help me, to change curl listen port?

curl doesn't listen to any port.

--

-- 

  / daniel.haxx.se
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

G F | 10 Sep 2009 21:14

FTPS via CURL/PHP

Having a real serious problem with this, and hoping someone can help
out.  I've been reading through stuff on curl.haxx.se since Monday.

Trying to download from / upload to an FTPS server using CURL/PHP
(CURL v. 7.10.6).  Using verbose:  with
'ftps://user:pass <at> ftp.example.com:990/test.txt' I receive a '230 User
logged in', and PWD yields '257 "/users/user" is current directory'.
PASV puts us into the correct transfer mode, and the correct file size
is reported for test.txt.  But the transfer fails.  The transcript at
that point reads:

> RETR test.txt
< 125 Downloading in ASCII file test.txt (9)
* Getting file with size: 9
* Received only partial file: 0 bytes
* Connection #0 left intact
* Closing connection #0

Searching for 'Received only partial file' yields very few helpful
results.  (Most of them seem to have to do with the C source code).
Can anybody at all tell me what could be happening?  What's causing
the 'Received only partial file'?  Does this mean that 0 bytes were
sent by the server in response to the RETR, or does it mean CURL/PHP
didn't know what to do with them (despite CURLOPT_FILE being set to a
writable file)?  If the server sent 0 bytes, what could be causing
that?

I'm using CURLOPT_SSL_VERIFYHOST, CURLOPT_SSL_VERIFYPEER, and a PEM
certificate that CURL/PHP seems to find without any trouble.  The fact
that it establishes a connection leads me to believe that SSL options
(Continue reading)

Daniel Stenberg | 10 Sep 2009 22:16
Picon
Favicon
Gravatar

Re: FTPS via CURL/PHP

On Thu, 10 Sep 2009, G F wrote:

> Trying to download from / upload to an FTPS server using CURL/PHP
> (CURL v. 7.10.6).

7.10.6 really? The 7.10.6 that was released in July 2003? Wow. You really 
shouldn't. The records count no less then 858 bug fixes made since then.

> < 125 Downloading in ASCII file test.txt (9)
> * Getting file with size: 9
> * Received only partial file: 0 bytes

This means the transfer was aborted prematurely and libcurl detected that it 
was supposed to send more bytes than it actually did.

--

-- 

  / daniel.haxx.se
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

Gilad Parann-Nissany | 10 Sep 2009 22:31

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

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


_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
G F | 10 Sep 2009 22:37

Re: FTPS via CURL/PHP

I'll try to get our server to upgrade its version of CURL.

But when you say that it "aborted prematurely and libcurl detected
that it was supposed to send more bytes than it actually did," is
there any indication what might have caused it to abort prematurely?
I can paste the entire CURL output if necessary.

Thanks very much,
Greg

On Thu, Sep 10, 2009 at 1:16 PM, Daniel Stenberg <daniel <at> haxx.se> wrote:
> On Thu, 10 Sep 2009, G F wrote:
>
>> Trying to download from / upload to an FTPS server using CURL/PHP
>> (CURL v. 7.10.6).
>
> 7.10.6 really? The 7.10.6 that was released in July 2003? Wow. You really
> shouldn't. The records count no less then 858 bug fixes made since then.
>
>> < 125 Downloading in ASCII file test.txt (9)
>> * Getting file with size: 9
>> * Received only partial file: 0 bytes
>
> This means the transfer was aborted prematurely and libcurl detected that it
> was supposed to send more bytes than it actually did.
>
> --
>
>  / daniel.haxx.se
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

Daniel Stenberg | 10 Sep 2009 22:42
Picon
Favicon
Gravatar

Re: FTPS via CURL/PHP

On Thu, 10 Sep 2009, G F wrote:

> But when you say that it "aborted prematurely and libcurl detected that it 
> was supposed to send more bytes than it actually did," is there any 
> indication what might have caused it to abort prematurely? I can paste the 
> entire CURL output if necessary.

An FTP transfer ends when the data transfer is closed. There's no other signal 
or mechnism to tell why it ends (other than the response code that is sent 
after the transfer's completion).

But really, chasing after problems in a 6 year old version is not my idea of 
fun.

--

-- 

  / daniel.haxx.se
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

Gilad Parann-Nissany | 10 Sep 2009 23:02

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

Based on Daniel's analysis this is a curl-and-PHP issue (and thanks to Daniel for the input). Does anyone on this curl-and-php mailing list have an insight to what is going on?

To recap and restate the issue based on Daniel's feedback:

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

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 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.

It seems that PHP thinks that it needs to use the file protocol (CURLPROTO_FILE). Why? I have only used HTTP and most of the time that works.

My questions are:

1. why does PHP/CURL sometimes make an attempt to use the filesystem somehow? Is it trying to cache the data I am streaming? Or something else?
2. Is there any way to control this behavior?

Note I prefer not to switch off "open_basedir" because it has a security benefit.

Regards
Gilad
__________________
Gilad Parann-Nissany
http://www.parann.net/


On Thu, Sep 10, 2009 at 23:40, Daniel Stenberg <daniel <at> haxx.se> wrote:
On Thu, 10 Sep 2009, Gilad Parann-Nissany wrote:

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

...


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.

No, that's not what it implies. It implies that the PHP/CURL code somehow detects something that it prevents you from doing and it tells you about it. If libcurl itself would do it the PHP/CURL layer would have no idea and wouldn't be able to tell you.


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 can tell you that libcurl does no such thing. I cannot tell you if there are situation when the PHP CURL extension might do so - as I don't know.


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?

Nope, it doesn't.


2. can you explain the conditions where this may happen and why?

No, I can't.


3. is there any way to configure cURL to control this behavior?

This is not a "cURL" issue, this is a PHP/CURL issue - as in the libcurl binding for PHP. libcurl doesn't have this behavior.

--

 / daniel.haxx.se

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
G F | 10 Sep 2009 23:08

Re: FTPS via CURL/PHP

Good point - I wouldn't want to either.  I've asked the team with
server access to get us upgraded.

Thanks for your time.
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

Gilad Parann-Nissany | 11 Sep 2009 14:45

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

Update on this issue: it seems like a real bug in PHP/CURL binding that occurs when you use the CURLOPT_INFILESIZE option and the value you set (the length) is "just right".

Bug reported in the php bug system. For details see http://bugs.php.net/?id=49531

Regards
Gilad
__________________
Gilad Parann-Nissany
http://www.parann.net/


On Fri, Sep 11, 2009 at 00:02, Gilad Parann-Nissany <gilad <at> parann.net> wrote:
Based on Daniel's analysis this is a curl-and-PHP issue (and thanks to Daniel for the input). Does anyone on this curl-and-php mailing list have an insight to what is going on?

To recap and restate the issue based on Daniel's feedback:


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

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 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.

It seems that PHP thinks that it needs to use the file protocol (CURLPROTO_FILE). Why? I have only used HTTP and most of the time that works.

My questions are:

1. why does PHP/CURL sometimes make an attempt to use the filesystem somehow? Is it trying to cache the data I am streaming? Or something else?
2. Is there any way to control this behavior?

Note I prefer not to switch off "open_basedir" because it has a security benefit.


Regards
Gilad
__________________
Gilad Parann-Nissany
http://www.parann.net/



On Thu, Sep 10, 2009 at 23:40, Daniel Stenberg <daniel <at> haxx.se> wrote:
On Thu, 10 Sep 2009, Gilad Parann-Nissany wrote:

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

...


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.

No, that's not what it implies. It implies that the PHP/CURL code somehow detects something that it prevents you from doing and it tells you about it. If libcurl itself would do it the PHP/CURL layer would have no idea and wouldn't be able to tell you.


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 can tell you that libcurl does no such thing. I cannot tell you if there are situation when the PHP CURL extension might do so - as I don't know.


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?

Nope, it doesn't.


2. can you explain the conditions where this may happen and why?

No, I can't.


3. is there any way to configure cURL to control this behavior?

This is not a "cURL" issue, this is a PHP/CURL issue - as in the libcurl binding for PHP. libcurl doesn't have this behavior.

--

 / daniel.haxx.se


_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

Gmane