Add wxWebCredentials and use it in SetCredentials()

Prefer using a class encapsulating both the user name and the password
to using a pair of variables.
This commit is contained in:
Vadim Zeitlin
2021-01-10 01:22:40 +01:00
parent fe197d7527
commit 1e6d6be8bb
9 changed files with 87 additions and 24 deletions

View File

@@ -16,6 +16,7 @@
#include "wx/event.h"
#include "wx/object.h"
#include "wx/secretstore.h"
#include "wx/stream.h"
#include "wx/versioninfo.h"
@@ -33,6 +34,22 @@ typedef wxObjectDataPtr<wxWebRequestImpl> wxWebRequestImplPtr;
typedef wxObjectDataPtr<wxWebResponseImpl> wxWebResponseImplPtr;
typedef wxObjectDataPtr<wxWebSessionImpl> wxWebSessionImplPtr;
class wxWebCredentials
{
public:
wxWebCredentials(const wxString& user, const wxSecretValue& password)
: m_user(user), m_password(password)
{
}
const wxString& GetUser() const { return m_user; }
const wxSecretValue& GetPassword() const { return m_password; }
private:
wxString m_user;
wxSecretValue m_password;
};
class WXDLLIMPEXP_NET wxWebAuthChallenge
{
public:
@@ -51,7 +68,7 @@ public:
Source GetSource() const;
void SetCredentials(const wxString& user, const wxString& password);
void SetCredentials(const wxWebCredentials& cred);
private:
// Ctor is used by wxWebRequest only.