Article View: borland.public.cppbuilder.internet.socket
Article #3019Re: IdHTTP authentication question
From: Michael Gillen
Date: Tue, 20 Dec 2005 14:56
Date: Tue, 20 Dec 2005 14:56
39 lines
2197 bytes
2197 bytes
No ideas?
Here's stripped down some example code.
if(IdHTTP->Connected())
IdHTTP->Disconnect();
IdHTTP->Request->BasicAuthentication = true;
IdHTTP->Request->Username = "admin"; // you can add an edit box to enable additional users
IdHTTP->Request->Password = EdtPassword->Text;
// This overrides the default Mozilla 3 signature which will cause an error
IdHTTP->Request->UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; .NET CLR
1.0.3705)";
IdHTTP->HandleRedirects = true; // Prevents the 302 error because of redirection
// Check for a password
if ( EdtPassword->Text.Length() < 1 )
{
MessageDlg("Please enter a password.", mtError, TMsgDlgButtons() << mbOK, 0);
EdtPassword->SetFocus();
return;
}
try
{
AnsiString S = AnsiString("http://")+EdtURL->Text+":"+EdtPort->Text+AnsiString("/");
AnsiString Resp = IdHTTP->Get(S);
// Remove newline characters for compatability between EPCR and LPC
UpdateStatus(Resp);
}
catch ( Exception &E )
{
IdHTTP->Disconnect(); // If the password is invalid, I get the error here.
// I cannot retry with a new password until the app is closed
// and restarted.
Application->ShowException(&E);
}
...
--
-Michael Gillen
Technical Details
Message-ID:
<43a829c4@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<43a1e28d$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,64f3cf05ca4f04e6 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Michael Gillen" <michael@gillenconsultinggroup-nospam.com> Subject: Re: IdHTTP authentication question Newsgroups: borland.public.cppbuilder.internet.socket References: <43a1e28d$1@newsgroups.borland.com> User-Agent: XanaNews/1.17.6.6 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 NNTP-Posting-Host: 67.122.199.249 Message-ID: <43a829c4@newsgroups.borland.com> Date: 20 Dec 2005 07:56:52 -0700 X-Trace: newsgroups.borland.com 1135094212 67.122.199.249 (20 Dec 2005 07:56:52 -0700) Lines: 39 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail