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

curl-and-php

Re: Error HTTP 502 caused by CURLOPT_RETURNTRANSFER ?

From: Stephen Pynenburg <spynenburg_at_gmail.com>
Date: Sun, 27 Jul 2008 12:43:56 -0400

I'm not sure why that would happen, but a quick fix that ought to work is to
use the output buffer - this will capture the return of curl_exec but not
print it out. It's not as good, performance wise, as using the actual cURL
function, but maybe someone who knows a bit more about the binding can help
you actually fix this :)

//set all your options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
ob_start();
curl_exec($ch);
$res = ob_get_contents();
ob_end_flush();

//parse $res as you please

-Stephen
On Fri, Jul 25, 2008 at 12:54 PM, Rodolphe Langumier - Kalyst <
rodolphe.langumier_at_kalyst.fr> wrote:

> Hi everyone,
>
> I'm annoyed with a very weird problem. In a few words my code (using curl
> obviously) produces a 502 HTTP error only if I disable RETURNTRANSFER. The
> problem is that I need to parse the page returned...
>
> Here's in detail what happens, and why it's weird :
>
> - I made a little software which connects on a website, gets identified
> using a cookie then submit a form.
> something very simple, that actually fully works on my server. (using
> apache)
> - I deployed my software on a pre-production server using IIS.
> - The identification step works fine, I save the cookie.
> -The next step : I submit the form using the cookie. And my script stops
> and the server returns the error HTTP 502. No errors from curl or the PHP
> script : everything is interrupted. And the error itself has not much sense
> to me 'Bad gateway'...
> - If I disable CURLOPT_RETURNTRANSFER, I receive the page I expect. But the
> results is printed and I can't use it afterwards.
>
> I spent quite some time searching for similar cases without success :
> either about IIS or curl itself.
> Sorry if my explanations are not very clear, english isn't my mother
> tongue. So if you need more details, I'd be happy to feed you with some
> inputs !
>
> Thanks in advance for any clues on my problem :-)
>
> Regards,
> Rodolphe.
>
>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-07-27