![]() |
![]() ![]() ![]() |
WinHTTP component.
|
type
|
TWinHTTPPasswordRequestEvent = procedure(Sender: TObject;
|
const Realm: String; var TryAgain: Boolean) of object;
|
|
property OnPasswordRequest: TWinHTTPPasswordRequestEvent;
|
The OnPasswordRequest event can be used to implement the dialog which asks user for his username and password to access the password protected Web area.
|
|
Set TryAgain parameter to True to retry the HTTP query with correct username and password. (Don't forget to specify correct login information in this event handler to Username and Password properties.)
|
![]() |
procedure TForm1.HTTP1PasswordRequest(Sender: TObject;
|
const Realm: String; var TryAgain: Boolean);
|
begin
|
{ UserPassForm is any form with two edit boxes used for entering the login information (username and password) }
|
UserPassForm.RealmLabel := Realm;
|
if UserPassForm.ShowModal = ID_OK then
|
begin
|
WinHTTP1.Username := UserPassForm.UsernameEdit.Text;
|
WinHTTP1.Password := UserPassForm.PasswordEdit.Text;
|
TryAgain := True; // Retry HTTP query (download attempt)
|
end;
|
end;
|
void __fastcall TForm1::WinHTTP1PasswordRequest(TObject *Sender,
|
AnsiString Realm, bool &TryAgain)
|
{
|
UserPassForm->RealmLabel = Realm;
|
if (UserPassForm->ShowModal() == ID_OK)
|
{
|
WinHTTP1->Username = UserPassForm->UsernameEdit->Text;
|
WinHTTP1->Password = UserPassForm->PasswordEdit->Text;
|
TryAgain = True; // Retry HTTP query (download attempt)
|
};
|
}
|
Username and Password properties; OnHTTPError event;
|
HTTP Status Codes.
|