🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #3693

Re: http 302 error (redirect)

#3693
From: Remy Lebeau (TeamB)
Date: Thu, 21 Jul 2005 21:05
60 lines
2930 bytes
"Blake Young" <blakeyoung@mail.utexas.edu> wrote in message
news:42e00af1$1@newsgroups.borland.com...

> Despite the fact that it has a secure URL (hence "https"), a
> username and password is NOT needed to download the file.

Perhaps not, but an SSL negotiation is still required.

> the response to the GET command is a 302 error, saying that
> the file has been moved.

As it should be.  See below.

> I believe the problem is that I cannot get either component to
> connect to the HTTPS location...

Yes, you can.  TIdHTTP has support for HTTPS URLs.

> they only try the HTTP location.

That may be the case for your TClientSocket code, but that is not the case
with TIdHTTP.

> Here is my code:

Your TClientSocket code is not HTTPS-aware at all.

>        ClientSocket1->Host = "webspace.utexas.edu";
>        ClientSocket1->Port = 80;

You are not accessing "https://webspace.utexas.edu" at all.  You are
accessing "http://webspace.utexas.edu" instead.  HTTPS runs on port 443, not
port 80.  That makes a big difference.

> The response I get from ReceiveText() should just be the single line
> of text that makes up the "version.txt" file

No, it should not, because you are not accessing the HTTPS URL at all.  You
can even see in the response from "http://webspace.utexas.edu" (port 80)
that you are being redirected to "https://webspace.utexas.edu" (port 443)
instead.

> The only thing I can think of is that maybe it's originally trying to go
to
> the non-secured URL first (i.e. http://webspace.utexas.edu/...) instead
> of the secure https location.

That is exactly what your TClientSocket code is doing.

> If this is indeed the problem, how can I use the component (either
> TClientSocket or TIdHTTP) to access the https URL?

For TClientSocket, you need to change the Port that is used.

For TIdHTTP, it handles HTTPS automatically, so you do not need to do
anything for it.


Gambit
Technical Details
Message-ID: <42e00ee5$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!meganewsservers.com!feeder2.on.meganewsservers.com!newshosting.com!nx02.iad01.newshosting.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <42e00af1$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,5aca12ad06e8e880
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <42e00af1$1@newsgroups.borland.com>
Subject: Re: http 302 error (redirect)
Date: Thu, 21 Jul 2005 14:05:53 -0700
Lines: 62
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <42e00ee5$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1121980133 68.69.17.41 (21 Jul 2005 14:08:53 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!meganewsservers.com!feeder2.on.meganewsservers.com!newshosting.com!nx02.iad01.newshosting.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail