cURL / Mailing Lists / curl-users / Single Mail


Re: I cannot log on !

From: Ralph Mitchell <>
Date: Fri, 14 Dec 2007 16:06:50 -0600

On Dec 14, 2007 3:43 PM, Jean Marie COUPRIE <> wrote:

> > Date: Thu, 13 Dec 2007 21:40:52 +0100 (CET)
> > From: Daniel Stenberg <>
> > On Thu, 13 Dec 2007, Jean Marie COUPRIE wrote:
> >
> >> Please add in the Man page of Curl (in big characters) a warning saying
> that
> >> if the application send several messages to answer 1 Curl request, Curl
> see
> >> (and give to the user) only the first one that may be very different
> from
> >> what a browser see.
> >
> > I don't see how that makes any sense. curl fetches the response from the
> > server. A single request gets a single response. I think you're
> confusing
> > matters, but I can't exactly figure out how.
> >
> > Can you please elaborate?
> Apparently "A single request gets a single response." is false if the
> server use a welcome message : After successful log on, the server send
> a message screen that say approximatively " Welcome userid, you have
> been connected, you will be redirected in a few seconds. If you are not,
> click here" then it send the first application screen. Curl reports only
> the welcome message, the user of a browser sees both.

The "multiple responses" are usually single pages. The first page saying
"welcome, you will be redirected" probably contains one of these:

   1) <meta http-equiv="refresh" content="5; URL=xxxxx"

   2) javascript with something like "top.location="new-url-to-go-to"

   3) a self-submitting form. i.e. there's a form full of hidden variables
in the body, which gets submitted due to:
        a) the body tag looks something like "<body

        b) a javascript block that contains "form[0].submit();", or
something similar

   4) some other method of making the browser leap off in another direction.

So, while the user is looking at the welcome page, the browser is counting
down from some number. When it hits zero, the browser then does the
*second* page fetch.

Trust me, this really is how it works, though the above list of redirect
methods is not exhaustive. There's one application in particular that I
have to work with which does 4 redirects between logging in and getting to
the target page, and none of the redirects are handled the same way.

You need to examine the first page you get back and see how it manages the
"redirect magic", then emulate that in your script.

Ralph Mitchell
Received on 2007-12-14