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

curl-and-php

Weird behaviour of curl with PHP

From: Friedrich Koester <friedrich28_at_gmx.de>
Date: Sat, 07 Apr 2007 11:53:12 +0200

Hello,

sometime Wednesday evening or Thursday morning, curl started behaving
strangely on our hosting provider's server. When calling more than one
page in a session (i.e. with one curl handler), we only get a "502 Bad
Gateway" Error back from the server (running under PHP4) or a blank page
(running under PHP5). If running under PHP4, there are also two lines in
the Apache Error log file:

[Thu Apr 05 10:18:25 2007] [error] [client xx.xx.xx.xx] proxy: error
reading status line from remote server www.mydomain.se
<http://www.meinedomain.de>
[Thu Apr 05 10:18:25 2007] [error] [client xx.xx.xx.xx] proxy: Error
reading from remote server returned by /myscript.php

(I have replaced our domain name by mydomain.se and the actual script
name with myscript.php here.)

I immediately contacted the hosting provider, but they didn't respond.
When I called later, they said they hadn't changed anything on the
server, and all technicians were out until Tuesday. Needless to say that
all the scripts still run OK on my local test install (Mac OS X) and
that I hadn't changed anything.

After some testing and trying, I found out that single pages could still
be retrieved. Even two consecutive calls for "regular" pages work. But
if two pages from a server are retrieved via HTTPS, the error occurs. If
you call curl_init() in between, then even two pages can be retrieved
via HTTPS in the same script. So I rewrote our interfaces (which are
very important to us) to call curl_init() before any page retrieval.

But I couldn't solve one problem: As soon as we need cookies - either
with an HTTPS or an HTTP connection - the script will not work. I can
retrieve the first page with the Cookie:-Header, and the cookies are
even stored in the file indicated in CURLOPT_COOKIEJAR. But when I then call
$this->ch = curl_init();
curl_setopt ($this->ch, CURLOPT_COOKIEFILE, $cfile);
curl_setopt ($this->ch, CURLOPT_COOKIEJAR, $cfile);
before retrieving the next page, the script will break again.

It seems like anything that connects two calls to a "curl session"
breaks. I am totally frustrated now. What do I need to tell our hosting
provider on Tuesday what they should do to fix this?

The install currently runs under Apache/2.0.54 (Debian GNU/Linux)
PHP/4.4.4 and libcurl/7.13.2 OpenSSL/0.9.7e zlib/1.2.1 libidn/0.5.13.

If you need more information, please ask. Any help is greatly appreciated!

Thank you and happy easter holidays
Friedrich
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-04-07