mirror of
https://github.com/appium/appium.git
synced 2026-10-29 04:36:39 +08:00
fix: Fix the request options for different keepAlive values (#367)
This commit is contained in:
@@ -125,7 +125,6 @@ class JWProxy {
|
||||
_.isString(content) ? content : JSON.stringify(content),
|
||||
{ length: LOG_OBJ_LENGTH });
|
||||
const reqOpts = {
|
||||
agent: false,
|
||||
url: newUrl,
|
||||
method,
|
||||
headers: {
|
||||
@@ -135,8 +134,18 @@ class JWProxy {
|
||||
},
|
||||
resolveWithFullResponse: true,
|
||||
timeout: this.timeout,
|
||||
forever: this.keepAlive,
|
||||
};
|
||||
if (this.keepAlive) {
|
||||
reqOpts.forever = true;
|
||||
// Setting `forever` option to `true` implicitly assigns
|
||||
// `agent` option to `http(s).Agent({keepAlive:true})`
|
||||
} else {
|
||||
// Setting `agent` option to `false` prevents the requests
|
||||
// module from using any connection pools, which enforces
|
||||
// new socket creation for each HTTP(S) request
|
||||
// (the default HTTP 1.0 behavior)
|
||||
reqOpts.agent = false;
|
||||
}
|
||||
if (util.hasValue(body)) {
|
||||
if (typeof body !== 'object') {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user