Beispiel #1
0
/*  
    function setCredentials(username: String?, password: String?, authType: String?): Void
 */
static EjsObj *http_setCredentials(Ejs *ejs, EjsHttp *hp, int argc, EjsObj **argv)
{
    cchar   *authType, *password, *user;

    user = (argc <= 0) ? 0 : ejsToMulti(ejs, argv[0]);
    password = (argc <= 1) ? 0 : ejsToMulti(ejs, argv[1]);
    authType = (argc <= 2) ? 0 : ejsToMulti(ejs, argv[2]);
    if (ejsIs(ejs, argv[0], Null)) {
        httpResetCredentials(hp->conn);
    } else {
        httpSetCredentials(hp->conn, user, password, authType);
    }
    return 0;
}
Beispiel #2
0
/*
    password and authType can be null
    User may be a combined user:password
 */
PUBLIC void httpSetCredentials(HttpConn *conn, cchar *username, cchar *password, cchar *authType)
{
    char    *ptok;

    httpResetCredentials(conn);
    if (password == NULL && strchr(username, ':') != 0) {
        conn->username = ssplit(sclone(username), ":", &ptok);
        conn->password = sclone(ptok);
    } else {
        conn->username = sclone(username);
        conn->password = sclone(password);
    }
    if (authType) {
        conn->authType = sclone(authType);
    }
}
Beispiel #3
0
/*  
    function reset(): Void
 */
static EjsObj *http_reset(Ejs *ejs, EjsHttp *hp, int argc, EjsObj **argv)
{
    httpResetCredentials(hp->conn);
    httpPrepClientConn(hp->conn, 0);
    return 0;
}