1 pièce(s) jointe(s)
TIdHTTPServer Indy Simple Authentification
Bonjour,
Je suis à la recherche d'une méthode pour récupérer les paramètres d'identification dans la procédure OnGetCommand du IdHttpServer de cette manière :
Url : http://gregory:admin@192.168.1.36/
Pourriez-vous m'éclairer sur le format de l'URL? je ne parviens pas à récupérer les paramètres d'identification. :calim2:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| { CommandGet }
procedure TFServerLib.CommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo;
AResponseInfo: TIdHTTPResponseInfo);
var
AuthPassword, AuthUsername: String;
begin
ARequestInfo.BasicAuthentication := True;
if not ARequestInfo.AuthExists then
begin
AResponseInfo.ResponseNo := 401;
AResponseInfo.ResponseText := 'Authentication required !';
AResponseInfo.WriteContent;
end
else
begin
AuthPassword := ARequestInfo.AuthPassword;
AuthUsername := ARequestInfo.AuthUsername;
if (AuthUsername.Equals('gregory')) and (AuthPassword.Equals('admin')) then
begin
AResponseInfo.ResponseNo := 200;
AResponseInfo.ResponseText := 'Password : ' + AuthPassword + ' , User : ' + AuthUsername;
AResponseInfo.WriteContent;
end
else
begin
AResponseInfo.ResponseNo := 401;
AResponseInfo.ResponseText := 'Err Auth : Password or Username !';
AResponseInfo.WriteContent;
end;
end;
end; |
Pièce jointe 658756
Merci