curl-and-php
RE: problem while redirecting with curl to an https
Date: Fri, 7 May 2004 20:26:07 +0200 (CEST)
On Fri, 7 May 2004, Lizet Peņa de Sola wrote:
Ok, I'll be a bit more lengthy and describe this with more details.
> The above code works fine, it passes all the POST parameters to the
> requested page and shows the page,
I'd like to make a drawing of how I view this:
(A) Browser <=> (B) Your HTTP server <=> (C) The HTTPS server
You send a POST (using PHP/curl) from B to C, and the results from that is
sent back to A.
> however all relative uri in the second page are taking the first page domain
> as their base uri, the page url isn't shown etc.
Of course, since the browser A is visiting the URL B, it has no idea that you
get the HTML from C.
> The http reference doc rfc2616 (downloadable from w3.org) is pretty
> strainght about the headers on a request, on a simple redirect with php
> header("Location: http://www.foo.com");
Yes, if your site (B) includes a Location: header back to (A) while at the
same time returning the correct HTTP response code, then the browser will
follow that hint.
> works fine except for POST methods.
In HTTP, you can return Location: headers to all requests.
> I included these two lines:
> $header[]="Location: https://https://www.foo.com";
> curl_setopt ($ch, CURLOPT_HTTPHEADER, $header);
... yes, and that makes you include a Location: header in the outgoing request
from B to C, which won't make browser A do anything. A Location: in a
request-header has no effect on C or the response from it anyway.
> As a result of your reply to a previous post of mine on the Curl discussion
> list in haxx.es where you made a comment saying I needed to send the proper
> headers.
You said you wanted the browser to display a different URL, and one way to
accomplish that is to return a Location: header back. From B to A.
But that would also mean that the browser would leave your page/site.
> The documentation of curl is pretty scarce as in
> http://www.php.net/manual/en/ref.curl.php where there is a list of
> predefined constants that can be used with curl_setopt function but not an
> explanation of the constants.
I know, but I'm not responsible for any of that. When you use PHP/curl you use
a binding that is adjusted for PHP that is ontop of libcurl.
I write libcurl, I don't do anything in PHP/curl. libcurl is about doing
client-side file transfers.
> The doc found in http://curl.haxx.se/docs/httpscripting.html handles the
> Curl library from the command line.
That's my backyard. You can also read
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html which is the libcurl
descriptions for most options that are also available and similarly working in
the php/curl interface.
> Please indicate me which other manuals should I read.
You need to understand the differences between A, B and C in my "drawing". I
don't know what manuals that takes.
-- Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se Dedicated custom curl help for hire: http://haxx.se/curl.htmlReceived on 2004-05-18