#23539 [Com]: curl_exec seems to produce strange results

From: Date: Thu, 15 May 2003 06:42:27 +0000
Subject: #23539 [Com]: curl_exec seems to produce strange results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-39688@lists.php.net to get a copy of this message
 ID:               23539
 Comment by:       daniel at haxx dot se
 Reported By:      ramato at squiz dot net
 Status:           Verified
 Bug Type:         cURL related
 Operating System: Redhat Linux 7.3
 PHP Version:      4.3.2RC2
 New Comment:

Ok, I've seen users of PHP/CURL mention this before, and for some
reason people tend to assume that the garbage is chunked
transfer-encoding data (which is not true, since libcurl deals with the
chunked data itself and hides that logic from the app).

One user says he solved the problem by using
curl_setopt(curlopt_returntransfer,1)
(http://curl.haxx.se/mail/curlphp-2003-04/0013.html). That could give
you a hint of where to look for this.

Looking at the current ext/curl/interface.c code in CVS, I can only see
a very minor bug that I think doesn't make any difference at this
point. Patch for this follows here:

diff -u -r1.15 interface.c
--- interface.c	9 May 2003 01:10:18 -0000	1.15
+++ interface.c	15 May 2003 06:40:56 -0000
@@ -374,7 +374,7 @@
 	
 	switch (t->method) {
 		case PHP_CURL_STDOUT:
-			PHPWRITE(data, size);
+			PHPWRITE(data, length);
 			break;
 		case PHP_CURL_FILE:
 			return fwrite(data, size, nmemb, t->fp);
@@ -483,7 +483,7 @@
 			if (ch->handlers->write->method == PHP_CURL_RETURN) {
 				smart_str_appendl(&ch->handlers->write->buf, data, (int) length);
 			} else {
-				PHPWRITE(data, size);
+				PHPWRITE(data, length);
 			}
 			break;
 		case PHP_CURL_FILE:


Previous Comments:
------------------------------------------------------------------------

[2003-05-14 21:03:55] iliaa@php.net

Daniel,

I do not believe it is curl_easy_perform(), who is at fault here, but
the strange text that I can see occurs every single time and definately
is not printed by anything inside PHP. Unfortunately I am not fluent in
libcurl source to give you much more information then that. I did
however write a small scirpt that is the equivalent of the above code
in C  (well, it does the same thing) and did not get any strange text.

------------------------------------------------------------------------

[2003-05-14 05:12:42] drhelper at mail dot ru

Snapshot php4-STABLE-200305140730 this bug
exist up to the point.

Any curl_exec() produces random text output.

------------------------------------------------------------------------

[2003-05-12 06:39:17] daniel at haxx dot se

Are you saying that curl_easy_perform() behaves wrongly or that you use
the output from it badly in the PHP/CURL glue code?

If it is the first, can you provide a small test code that shows the
problem?

(libcurl maintainer)

------------------------------------------------------------------------

[2003-05-08 20:12:39] iliaa@php.net

The output (garbage) actually does not come from PHP but rather from
curl_easy_perform(). I am guessing it is a result of some value not
being initialized and random data is being treated as a 'real' value.

------------------------------------------------------------------------

[2003-05-08 03:29:27] edink@php.net

I can reproduce the problem.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/23539

-- 
Edit this bug report at http://bugs.php.net/?id=23539&edit=1



Thread (11 messages)

« previous php.bugs (#39688) next »