curl-and-php
Re: Re: Error HTTP 502 caused by CURLOPT_RETURNTRANSFER ?
Date: Mon, 28 Jul 2008 17:15:02 +0200
Finally I found a solution to my problem. A stupid problem hidden by a
strange webserver behaviour :-)
The CURLOPT_VERBOSE option produces some uncatchable data (at least in IIS)
The response to my query produced a IIS error in some way, while in the
two other queries of my script I just get curl history printed out (and
not poping an HTTP 502 page). I just had to disable the verbose option
to have it work correctly. dumb problem, but obviously I left verbose
active to try to have as much data as possible...)
For information, using php command line I found the output I expected
(well almost, the verbose data was there too).
> From: Stephen Pynenburg <spynenburg_at_gmail.com
<mailto:spynenburg_at_gmail.com?Subject=Re:%20Error%20HTTP%20502%20caused%20by%20CURLOPT_RETURNTRANSFER%20?>>
> 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
Received on 2008-07-28