Thread View: borland.public.cppbuilder.internet.socket
5 messages
5 total messages
Started by Michael Gillen
Thu, 15 Dec 2005 20:39
IdHTTP authentication question
Author: Michael Gillen
Date: Thu, 15 Dec 2005 20:39
Date: Thu, 15 Dec 2005 20:39
12 lines
1250 bytes
1250 bytes
Indy 9.0.18 BCB6 I am able to login to the web page fine. If I first use an invalid password, the connection is properly rejected. After a rejection, issue an IdHTTP->Disconnect();. Correcting the password still results in a rejection. I must close the application and restart it to use the correct the password and log-in. What must I do to restart the connection fresh? -- -Michael Gillen
Re: IdHTTP authentication question
Author: 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
Re: IdHTTP authentication question
Author: Michael Gillen
Date: Tue, 03 Jan 2006 13:31
Date: Tue, 03 Jan 2006 13:31
5 lines
998 bytes
998 bytes
No Ideas? -- -Michael Gillen
Re: IdHTTP authentication question
Author: Remy Lebeau (TeamB)
Date: Thu, 26 Jan 2006 08:00
Date: Thu, 26 Jan 2006 08:00
14 lines
1177 bytes
1177 bytes
"Michael Gillen" <michael@gillenconsultinggroup-nospam.com> wrote in message news:43a1e28d$1@newsgroups.borland.com... > Indy 9.0.18 Try upgrading to the 9.0.50 snapshot and see if the problem still persits. > BCB6 I am assuming that you already removed Indy 8 from your machine? Gambit
Re: IdHTTP authentication question
Author: Remy Lebeau (TeamB)
Date: Thu, 26 Jan 2006 08:06
Date: Thu, 26 Jan 2006 08:06
29 lines
1804 bytes
1804 bytes
"Michael Gillen" <michael@gillenconsultinggroup-nospam.com> wrote in message
news:43a829c4@newsgroups.borland.com...
> IdHTTP->Request->BasicAuthentication = true;
> IdHTTP->Request->Username = "admin"; // you can add an edit box to enable
additional users
> IdHTTP->Request->Password = EdtPassword->Text;
Try also resetting the Authentication property:
if( IdHTTP->Request->Authentication )
IdHTTP->Request->Authentication->Reset();
Or:
if( IdHTTP->Request->Authentication )
{
delete IdHTTP->Request->Authentication;
IdHTTP->Request->Authentication = NULL;
}
Also, rather than waiting for a rejection-related exception to be thrown,
you can use the OnAuthorization event to dynamically change the username
and/or password. If you set the Handled parameter to True, then TIdHTTP
will automatically retry to login with the new values.
Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads