Add support to change the user agent.
This commit is contained in:
parent
24d6892261
commit
a679573bf3
1
src/interface/IConfig.d.ts
vendored
1
src/interface/IConfig.d.ts
vendored
@ -22,6 +22,7 @@ interface IConfig {
|
||||
unlog?: boolean;
|
||||
retry?: number;
|
||||
// Login options
|
||||
userAgent?: string;
|
||||
logUsingApi?: boolean;
|
||||
logUsingCookie?: boolean;
|
||||
crSessionUrl?: string;
|
||||
|
||||
@ -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)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user