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

curl-and-php

RE: problem while redirecting with curl to an https

From: Lizet Peņa de Sola <lizet_at_krosslink.com>
Date: Tue, 11 May 2004 09:50:19 -0500

Hello Daniel, the drawing is perfectly clear, so my big mistake was
trying to send the headers from B to C and expecting them back in A, I
see now. I tried then to modify the addresses present in the response I
get from C in B, since they were relative uris and got their base uri
from B not C. The modification was fine, but each time I tried to go to
a link in A I got in troubles due to the session variables, ie, once I
get a response in B from C the session data is not present in B anymore
=> I ended up with a intermediate page with a form that submits itself
in the onLoad of the page to C :\, I know, it's not a very elegant
solution.
Thanks for all the replies,
Lizet

_______________________________________

Caribbean Property Corporation Ltd.

Miramar Trade Center

Edif Barcelona Ofic. 401

Miramar. Havana

www.caribbeanpropertycorp.com

Tel: 53-7-2047934

Fax: 53-7-2047934

_________________________________________

Note: This communication is strictly confidential and is intended solely
for the person to whom it is addressed. If you are not the intended
recipient of this message, please be advised that any reproduction,
distribution or communication of this message is strictly prohibited. If
you have received this message in error, please notify us immediately
and destroy the original.

-----Original Message-----
From: curl-and-php-bounces_at_cool.haxx.se
[mailto:curl-and-php-bounces_at_cool.haxx.se] On Behalf Of Daniel Stenberg
Sent: Friday, May 07, 2004 1:26 PM
To: using curl with PHP
Subject: RE: problem while redirecting with curl to an https

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.html
Received on 2004-05-11