Add support to change the user agent.

This commit is contained in:
Godzil 2018-08-01 21:26:11 +01:00
parent 24d6892261
commit a679573bf3
2 changed files with 11 additions and 1 deletions

View File

@ -22,6 +22,7 @@ interface IConfig {
unlog?: boolean;
retry?: number;
// Login options
userAgent?: string;
logUsingApi?: boolean;
logUsingCookie?: boolean;
crSessionUrl?: string;

View File

@ -183,6 +183,11 @@ export function get(config: IConfig, options: string|request.Options, done: (err
loadCookies(config);
}
if (config.userAgent)
{
defaultHeaders['User-Agent'] = config.userAgent;
}
authenticate(config, (err) =>
{
if (err)
@ -209,6 +214,11 @@ export function post(config: IConfig, options: request.Options, done: (err: Erro
loadCookies(config);
}
if (config.userAgent)
{
defaultHeaders['User-Agent'] = config.userAgent;
}
authenticate(config, (err) =>
{
if (err)
@ -375,7 +385,6 @@ function authenticate(config: IConfig, done: (err: Error) => void)
});
});
}
});
}