Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
request-proxy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
request-proxy
Commits
28fbaf61
Commit
28fbaf61
authored
Dec 21, 2017
by
xzj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加timeout配置
parent
756a043a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
index.js
index.js
+6
-4
No files found.
index.js
View file @
28fbaf61
...
@@ -18,7 +18,7 @@ module.exports = function (options) {
...
@@ -18,7 +18,7 @@ module.exports = function (options) {
// 空闲的 KeepAlive socket 最长可以存活30秒
// 空闲的 KeepAlive socket 最长可以存活30秒
freeSocketKeepAliveTimeout
:
30000
freeSocketKeepAliveTimeout
:
30000
},
},
timeout
:
15000
// 15秒超时
timeout
:
15000
}
}
options
=
Object
.
assign
({},
optionsDefault
,
options
)
options
=
Object
.
assign
({},
optionsDefault
,
options
)
...
@@ -30,7 +30,8 @@ module.exports = function (options) {
...
@@ -30,7 +30,8 @@ module.exports = function (options) {
const
curlDefault
=
{
const
curlDefault
=
{
followRedirect
:
false
,
followRedirect
:
false
,
json
:
true
,
json
:
true
,
time
:
false
time
:
false
,
timeout
:
options
.
timeout
}
}
/**
/**
...
@@ -43,7 +44,8 @@ module.exports = function (options) {
...
@@ -43,7 +44,8 @@ module.exports = function (options) {
}
}
const
pipeDefault
=
{
const
pipeDefault
=
{
time
:
false
time
:
false
,
timeout
:
options
.
timeout
}
}
const
httpAgent
=
new
Agent
(
options
.
agent
);
const
httpAgent
=
new
Agent
(
options
.
agent
);
...
@@ -110,7 +112,7 @@ module.exports = function (options) {
...
@@ -110,7 +112,7 @@ module.exports = function (options) {
option
.
agent
=
httpsAgent
option
.
agent
=
httpsAgent
}
}
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
let
r
=
ctx
.
req
.
pipe
(
request
Ex
(
option
))
let
r
=
ctx
.
req
.
pipe
(
request
(
option
))
r
.
on
(
'
error
'
,
function
(
err
)
{
r
.
on
(
'
error
'
,
function
(
err
)
{
reject
(
err
);
reject
(
err
);
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment