Sets the basic authentication string for the website (if the site uses this method). Once set all requests to the target website will be submitted with this string in the HTTP header.
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzWebhost::AuthBasic | (const char*,const char*,) |
Declared in file: hzHttpClient.h
Defined in file : hzHttpClient.cpp
Function Logic:
Function body:
hzEcode hzWebhost::AuthBasic (const char* username)const char* password,
{
// Sets the basic authentication string for the website (if the site uses this method). Once set all requests to the target website will be
// submitted with this string in the HTTP header.
//
// Arguments: 1) username The user account username
// 2) password The user account password
//
// Returns: E_ARGUMENT If either the username or password is not supplied
// E_OK If the root is added
_hzfunc("hzWebhost::AuthBasic") ;
hzChain Enc ; // The encrypted sequence
hzChain Raw ; // The raw sequence
if (!username || !username[0]|| !password || !password[0])
{
threadLog("Must supply both a username and password\n") ;
return E_ARGUMENT ;
}
Raw << username ;
Raw.AddByte(CHAR_COLON) ;
Raw << password ;
Base64Encode(Enc, Raw) ;
HC.m_AuthBasic = m_AuthBasic = Enc ;
return E_OK ;
}