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;
|
unlog?: boolean;
|
||||||
retry?: number;
|
retry?: number;
|
||||||
// Login options
|
// Login options
|
||||||
|
userAgent?: string;
|
||||||
logUsingApi?: boolean;
|
logUsingApi?: boolean;
|
||||||
logUsingCookie?: boolean;
|
logUsingCookie?: boolean;
|
||||||
crSessionUrl?: string;
|
crSessionUrl?: string;
|
||||||
|
|||||||
@ -183,6 +183,11 @@ export function get(config: IConfig, options: string|request.Options, done: (err
|
|||||||
loadCookies(config);
|
loadCookies(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.userAgent)
|
||||||
|
{
|
||||||
|
defaultHeaders['User-Agent'] = config.userAgent;
|
||||||
|
}
|
||||||
|
|
||||||
authenticate(config, (err) =>
|
authenticate(config, (err) =>
|
||||||
{
|
{
|
||||||
if (err)
|
if (err)
|
||||||
@ -209,6 +214,11 @@ export function post(config: IConfig, options: request.Options, done: (err: Erro
|
|||||||
loadCookies(config);
|
loadCookies(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.userAgent)
|
||||||
|
{
|
||||||
|
defaultHeaders['User-Agent'] = config.userAgent;
|
||||||
|
}
|
||||||
|
|
||||||
authenticate(config, (err) =>
|
authenticate(config, (err) =>
|
||||||
{
|
{
|
||||||
if (err)
|
if (err)
|
||||||
@ -375,7 +385,6 @@ function authenticate(config: IConfig, done: (err: Error) => void)
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user