🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

http 302 error (redirect)

#3691
From: Blake Young
Date: Thu, 21 Jul 2005 20:51
69 lines
3189 bytes
This is the location of the file I'm trying to download via my program:
https://webspace.utexas.edu/youngba2/www/winboxer/version.txt

Despite the fact that it has a secure URL (hence "https"), a username and 
password is NOT needed to download the file.  I tried using both the 
TClientSocket and TIdHTTP components, but both of them are giving me the 
same hassles.  Namely, the response to the GET command is a 302 error, 
saying that the file has been moved.  I believe the problem is that I cannot 
get either component to connect to the HTTPS location...they only try the 
HTTP location.  This may be clearer after reading the rest of my post.  Here 
is my code:


void __fastcall TForm1::Button2Click(TObject *Sender)
{
    if (!ClientSocket1->Active)
    {
        ClientSocket1->Host = "webspace.utexas.edu";
        ClientSocket1->Port = 80;
        ClientSocket1->ClientType = ctNonBlocking;

        ClientSocket1->Open();
    }
}

void __fastcall TForm1::ClientSocket1Connect(TObject *Sender,
      TCustomWinSocket *Socket)
{
    ClientSocket1->Socket->SendText("GET /youngba2/www/winboxer/version.txt 
HTTP/1.0\r\n\r\n");

}

void __fastcall TForm1::ClientSocket1Read(TObject *Sender,
      TCustomWinSocket *Socket)
{
    AnsiString response = Socket->ReceiveText();
    Memo1->Lines->Add("File contents: " + response);
}


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


HTTP/1.1 302 Found
Date: Thu, 21 Jul 2005 20:42:33 GMT
Server: Apache
Location: https://webspace.utexas.edu/youngba2/www/winboxer/version.txt
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>302 Found</TITLE>
</HEAD><BODY>
<H1>Found</H1>
The document has moved <A 
HREF="https://webspace.utexas.edu/youngba2/www/winboxer/version.txt">here</A>.<P>
</BODY></HTML>


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.  If this is indeed the problem, how can I use the 
component (either TClientSocket or TIdHTTP) to access the https URL?

Thanks
Blake 
Technical Details
Message-ID: <42e00af1$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,5aca12ad06e8e880,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Blake Young" <blakeyoung@mail.utexas.edu>
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: http 302 error (redirect)
Date: Thu, 21 Jul 2005 15:51:57 -0500
Lines: 71
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 68.91.216.87
Message-ID: <42e00af1$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1121979121 68.91.216.87 (21 Jul 2005 13:52:01 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail