473,788 Members | 2,848 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

POST with curl causing Apache to lock up

Leo
Can anyone help or offer some explanation with this problem:

I'm trying to do a POST from one of my PHP pages, to another page on my
site using curl.
To maintain the session I'm sending the current session cookie in the
headers using

$headerArray = array("Cookie: " . session_name() . "=" .
session_id());

then

curl_setopt( $ch, CURLOPT_HEADER, 1 );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIE LDS, $postArray );
curl_setopt( $ch, CURLOPT_FOLLOWL OCATION, 0 );
curl_setopt( $ch, CURLOPT_HTTPHEA DER, $headerArray);
curl_exec( $ch );

The problem is, once this is submitted, Apache goes into an infinite
loop and has to be restarted. This only happens when I send the
current session cookie, if I change it slightly there's no problem
(although obviously the session is lost).

There seems to be mention of a similar problem on the post called 'CURL
and $_SESSION problem' but the guy is trying to achieve something
different so it doesn't get addressed.

Very grateful for any help with this!

Apr 7 '06 #1
3 3304
Hello,

on 04/07/2006 07:14 AM Leo said the following:
Can anyone help or offer some explanation with this problem:

I'm trying to do a POST from one of my PHP pages, to another page on my
site using curl.
To maintain the session I'm sending the current session cookie in the
headers using

$headerArray = array("Cookie: " . session_name() . "=" .
session_id());

then

curl_setopt( $ch, CURLOPT_HEADER, 1 );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIE LDS, $postArray );
curl_setopt( $ch, CURLOPT_FOLLOWL OCATION, 0 );
curl_setopt( $ch, CURLOPT_HTTPHEA DER, $headerArray);
curl_exec( $ch );

The problem is, once this is submitted, Apache goes into an infinite
loop and has to be restarted. This only happens when I send the
current session cookie, if I change it slightly there's no problem
(although obviously the session is lost).

There seems to be mention of a similar problem on the post called 'CURL
and $_SESSION problem' but the guy is trying to achieve something
different so it doesn't get addressed.


It seems like a bug in the Curl library.

You may want to try this HTTP client class. You can enable debug output
and see the HTTP dialog to figure exactly what is going on. It supports
cookie handling, so it should work for your purposes:

http://www.phpclasses.org/httpclient
--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Apr 7 '06 #2
>I'm trying to do a POST from one of my PHP pages, to another page on my
site using curl.
To maintain the session I'm sending the current session cookie in the
headers using

$headerArray = array("Cookie: " . session_name() . "=" .
session_id() );


As I recall, PHP locks sessions so the same session can't be used
simultaneously by two different hits in the same session. If it
didn't do this you'd have to lock session variables in individual
PHP pages to avoid getting a mess when two PHP scripts try to update
the same variables simultaneously. (For instance, a per-session
hit counter might lose counts).

Ordinarily, hits from the same session (e.g. the page and associated
images, or the page and several frames, which might also be delivered
by PHP pages) are just delayed. However, if Page A tries to use
PHP to make a hit on Page B on the same server using the same
session, PHP won't start running the Page B code until Page A
finishes running, but Page A won't finish running until Page B is
finished outputting. DEADLOCK!

The only solution I know of is to call session_write_c lose() in
Page A before starting the hit on Page B. This means you can't
change any session variables in Page A (and have the changes take)
after this point. Another workaround is to NOT try to use the same
session (which may have its own significant problems, like having
to log in with CURL).

Gordon L. Burditt

Apr 7 '06 #3
Leo
Thanks for the answers, I'll give the session_write_c lose a try as I'm
calling exit() straight after the curl post anyway.

Leo

Apr 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2934
by: Haluk Durmus | last post by:
Hello I checked out openssl,mm,apr,apr-util,apache 2,curl,libxml and php from cvs. php couse an ERROR I did the following steps:
0
2721
by: Ville Mattila | last post by:
Hello readers, I'm trying to install the latest PHP4 version from the scratch. The configure string is following: ../configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-curl --enable-exif --enable-mbsting=all --with-gd --with-openssl --with-zlib-dir=/usr --with-zlib Everything goes well until the cURL should be configured. At that point, I will encounter an error like this:
3
6332
by: Chris Fortune | last post by:
# uname -a Linux stargate.mxc-online.net 2.4.20-021stab022.2.777-smp #1 SMP Wed Jul 28 17:12:37 MSD 2004 i686 i686 i386 GNU/Linux I recompiled PHP with mcrypt, openssl, and curl phpinfo(): http://www.canadiandropshipping.com/hello.php3 Does anyone know why this ssl curl test fails? http://www.canadiandropshipping.com...t/diag_curl.php
0
1520
by: jsaint | last post by:
I'm using php 5.1.2 on apache 2.0.54 and am trying to use curl to connect to an ssl server. Curl works fine using http, and the command-line client works with https. But, in php, I just get error 7 when trying to connect through https. So, the problem would seem to be with php's bundled curl support. I am on WinXP, and everything is installed through binaries. Here's an example of my code: $ch = curl_init("https://login.yahoo.com"); ...
0
10712
by: mahesh anasuri | last post by:
Hi all, I am new to this mailing list. Thankful if any one is using curl/linux version to and worked on Https. I have created certificates (PEM format) for client and server using openSSL. I am using Apache server/Linux platform and started server with "server certificate". I configured server to listen HTTPS service at port 443. I downloaded download.txt correctly from server using command as $curl --cacert cacert.pem ...
4
12168
by: BinnyVA | last post by:
Hi, I am using PHP 5.1.2 with curl enabled. But whenever I try to use curl to fetch a url, it fails - 'curl_exec()' returns nothing. But if I try to execute the same file in CLI - like 'php curl.php', the script works properly. However if I try it in a browser, nothing is returned. The code is...
4
5563
by: Terry | last post by:
I'm using curl to invoke a php script on the same site/server. It works great, but if I call it again while it's still running, nothing happens. Why? Can that be fixed? Why use curl? To make it run in the background. My host can't use exec nor flush the output to the browser. But, I can use curl and timeout.
3
3543
by: Matthias Leopold | last post by:
hi i've got problems getting php4 scripts which use curl to work on RHEL4 (Nahant Update 4) and CentOS 4.4. when the script is accessed the browser "hangs", after a couple of minutes i'm prompted to save the php-file, obviously nothing is executed. what i've checked: ..) curl in php works with a selfcompiled php5 binary executed via cgi on the same server
3
2634
by: k.rollman | last post by:
I am having a problem using cURL to create an https connection on a non-standard port (440). Using curl_setopt to set the port to 440 has no effect, and I get the following from curl's verbose output. * About to connect() to xxx.xxx.xxx.xxx port 443 * Connected to xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx) port 443 If I put ':440' in the url, I get the following and an error code of 7. * About to connect() to xxx.xxx.xxx.xxx port 440
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.