Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
antSword
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HuangJunbo
antSword
Commits
9c156004
Commit
9c156004
authored
Jun 29, 2016
by
Antoor
Committed by
GitHub
Jun 29, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #60 from antoor/v2.0-beta-ignore-https
v2.0-beta::Ignore HTTPS Certificate
parents
4b765483
c80a5526
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
+23
-3
request.js
modules/request.js
+6
-2
index.js
node_modules/superagent/lib/node/index.js
+15
-0
base.js
source/core/base.js
+2
-1
No files found.
modules/request.js
View file @
9c156004
...
...
@@ -91,15 +91,17 @@ class Request {
* @return {[type]} [description]
*/
onRequest
(
event
,
opts
)
{
logger
.
debug
(
'onRequest::opts'
,
opts
);
logger
.
debug
(
'onRequest::url'
,
opts
[
'url'
]);
logger
.
debug
(
'onRequest::data'
,
opts
[
'data'
]);
superagent
.
post
(
opts
[
'url'
])
.
set
(
'User-Agent'
,
USER_AGENT
)
.
proxy
(
APROXY_CONF
[
'uri'
])
.
type
(
'form'
)
// 超时
.
timeout
(
REQ_TIMEOUT
)
// 忽略HTTPS
.
ignoreHTTPS
(
opts
[
'ignoreHTTPS'
])
.
send
(
opts
[
'data'
])
.
parse
((
res
,
callback
)
=>
{
this
.
parse
(
opts
[
'tag_s'
],
opts
[
'tag_e'
],
(
chunk
)
=>
{
...
...
@@ -145,6 +147,8 @@ class Request {
.
type
(
'form'
)
// 设置超时会导致文件过大时写入出错
// .timeout(timeout)
// 忽略HTTPS
.
ignoreHTTPS
(
opts
[
'ignoreHTTPS'
])
.
send
(
opts
[
'data'
])
.
pipe
(
through
(
(
chunk
)
=>
{
...
...
node_modules/superagent/lib/node/index.js
View file @
9c156004
...
...
@@ -589,6 +589,17 @@ Request.prototype.ca = function(cert){
return
this
;
};
/**
* 忽略HTTPS证书
* @param {[type]} ignore [description]
* @return {[type]} [description]
*/
Request
.
prototype
.
ignoreHTTPS
=
function
(
ignore
)
{
this
.
_ignoreHttps
=
!
ignore
;
process
.
env
.
NODE_TLS_REJECT_UNAUTHORIZED
=
ignore
?
'0'
:
undefined
;
return
this
;
};
/**
* Return an http[s] request.
*
...
...
@@ -615,6 +626,10 @@ Request.prototype.request = function(){
options
.
host
=
url
.
hostname
;
options
.
ca
=
this
.
_ca
;
options
.
agent
=
this
.
_agent
;
// 卧槽,设置了这么多选项都没用,不过还好解决了,先留着吧。。
// options.requestCert = this._ignoreHttps;
// options.strictSSL = false;
// options.rejectUnhauthorized = false;
// initiate request
var
mod
=
exports
.
protocols
[
url
.
protocol
];
...
...
source/core/base.js
View file @
9c156004
...
...
@@ -215,7 +215,8 @@ class Base {
data
:
opt
[
'data'
],
tag_s
:
opt
[
'tag_s'
],
tag_e
:
opt
[
'tag_e'
],
encode
:
this
.
__opts__
[
'encode'
]
encode
:
this
.
__opts__
[
'encode'
],
ignoreHTTPS
:
(
this
.
__opts__
[
'otherConf'
]
||
{})[
'ignore-https'
]
===
1
});
})
}
...
...
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