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

curl-and-php

Re: POSTing

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 12 Apr 2002 14:56:39 +0200 (MET DST)

On Fri, 12 Apr 2002, Sam Ramsay wrote:

> First... Hello list... Another new subscriber for you.

Welcome to our merry corner of the world!

> cURL works perfectly POSTing the relevant data, however the URL (in the
> location bar) remains the same (i.e. mine) rather than the URL I have just
> POSTed to (the external one)... This means that the links on the external
> page don't work as they are trying to be relative to my URL not theirs.

I've seen this confusion several times, and I'm not sure how to explain the
situation properly so that people understand. I think I'm burried too deep in
all the gory details.

What happens when you use curl to do the POST, is that it fires away a
request to the remote server and it receives a response. All that is done
within your program. Of course it doesn't affect the location of the browser
that watches the output from your program.

The browser that browses your PHP script is not moved anywhere and thus the
URL in the "location bar" remains the same until your PHP program tells it to
go somewhere (using Location:) or when the user clicks on a link (or
similar).

Curl is working as a http client from within your program and it does the
POST from the machine that runs your program, the server that runs your PHP
interpreter. Therefore, you cannot expect the browser to go somewhere else.
No one told it to.

If you want to present the results of the POST to the browser/user, then
fine, you can output it and the browser will see it, but as that other site
returned a page with HTML that might've used relative links etc just
outputting anothet site's HTML plainly may not be what you want.

If you want to POST and you want the browser to actually have the "location
bar" updated to that remote site, well then you must let the browser do the
POST. I can't see how curl can help you do that.

> Is this a limitation of cURL or is there something simple (it could be
> complex but I usually find that these solutions cause you to say "Oh of
> COURSE... I knew that") that needs to be added/altered/...

You could say that this is a "limitation" of curl. I would actuall rather say
that this is the essence of the powers curl offers.

It might also be so that I have completely misunderstood everything you said
and I've just written lots of gibberish you couldn't care less about...

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-04-12