cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl handling 403;4 redirection

From: Ralph Mitchell <ralphmitchell_at_gmail.com>
Date: Thu, 25 Nov 2010 12:08:48 -0500

On Thu, Nov 25, 2010 at 10:11 AM, Chris Hatko <chatko_at_gmail.com> wrote:

> Hi,
>
> I'm accessing an http page which the server redirect to an https page.
> This is done via a 403:4 error page which contains custom javascript code to
> do the redirection (via window.location). This work in all major browser,
> but only loads 403;4 page in curl and does not redirect. I've tried several
> options from the curl command line but nothing seems to work. Ideally i need
> to have this working in libcurl. Any ideas?
>
> The error redirection page is:
>
> <html>
> <head>
> <script language="JavaScript">
> <!-- begin hide
> // This page is intended to be used as a Custom Error page for error 403;4
> "Forb
> idden - SSL required"
> // It redirects HTTP requests to HTTPS
>
> function goElseWhere()
> {
> var oldURL = window.location.hostname + window.location.pathname +
> window.loca
> tion.search;
> var newURL = "https://" + oldURL;
> window.location = newURL;
> }
> goElseWhere();
>
> // end hide -->
> </script>
> </head>
> <body>
> </body>
> </html>
>

As long as the reconstructed oldURL is the same as the original url you
start with, you could simply go there, discard the response, edit oldURL to
make it https, then go to that page.

Actually, if the redirect page doesn't send cookies or anything else, you
could probably just go direct to the https url without bothering to hit the
unsecure one.

Just because the page has javascript doesn't mean you have to evaluate it.

Ralph Mitchell

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-11-25