eZ Community » Forums » Developer » Curl internal request failed
expandshrink

Curl internal request failed

Curl internal request failed

Friday 27 January 2012 2:42:15 pm - 3 replies

HI All,

I tried to fetch the result of "foo_module/foo_view" with the following code in eZ Publish, but the server just hanged up:

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'http://localhost/foo_module/foo_view');
curl_setopt($ch,CURLOPT_HTTPGET,true);
curl_setopt($ch,CURLOPT_COOKIE,'EZSESSID=xxxxxxxxxxxxx');
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
$out = curl_exec($ch);
curl_close($ch);

The code works fine with php cli and it also works in eZ Publish if I comment out the line of "CURLOPT_COOKIE". However, the "foo_module/foo_view" page is stateful, so session cookie is needed.

Looks like, eZ Publish does not allow internal curl request with session cookie header.

Can someone advise?

Kind regards,

Michael

Friday 27 January 2012 6:12:01 pm

I also have had similar strange problems while developing the debugger for ggwebservices.

Btw, I recommend using that extension to debug hhtp calls from eZ to itself.

I think the problem comes from some cache-lock or other locking happening: the called page will not execute as long as the caller page does not finish. All you can get is a timeout.

I "solved" it (iirc) by using a separate siteaccess for my http call.

Last words of advice: why run an http call instead of a module rerun from within php code?

Monday 30 January 2012 4:21:57 pm

Hi Gaetano,

Thanks a lot for your feedback.

The reason that I use http call instead of a module return is: we need develop some ajax services (e.g, captcha validation, email checks and etc) and we want to re-use the ajax services for both the client and server-side validation.

For stateless services (e.g, email checks and etc), it's okay because we don't need pass the 'COOKIE' header. However, for stateful services (e.g, captcha validation), we must pass the "COOKIE" header, which, as per our discussion, will cause a time-out error within the same siteaccess.

Besides, since ajax services will terminate the process with "eZExecution::cleanExit()", it's also impossible to get the module result with $module->run().

This issue may cause an other problem: how can we get the full html source ( pagelayout + module_result ) of a stateful page?

Kind regards,

Michael

Friday 03 February 2012 3:56:05 am

By the way, I've raised an issue about this at http://issues.ez.no/IssueView.php?Id=19102&activeItem=1

It will be great if this can be resolved in the future, because this will enable a lot of advanced features and possibilities and I'm really looking forward to it.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from