dv-browser 2.5.3 → 2.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +26 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -18,6 +18,10 @@ let DvBrowser = function (_config) {
|
|
|
18
18
|
connection: 'close',
|
|
19
19
|
proxyConnection: 'close',
|
|
20
20
|
xhr: false,
|
|
21
|
+
origin: null,
|
|
22
|
+
authBasic: null,
|
|
23
|
+
authBearer: null,
|
|
24
|
+
noDeflate: false,
|
|
21
25
|
}, _config);
|
|
22
26
|
|
|
23
27
|
const cookiejar = new CookieJar(null);
|
|
@@ -70,16 +74,33 @@ let DvBrowser = function (_config) {
|
|
|
70
74
|
if (!options.contentType && options.postData) {
|
|
71
75
|
options.contentType = 'application/x-www-form-urlencoded';
|
|
72
76
|
}
|
|
73
|
-
|
|
77
|
+
if (options.contentType) {
|
|
78
|
+
headers.push('Content-Type: ' + options.contentType);
|
|
79
|
+
}
|
|
74
80
|
headers.push('Connection: ' + options['connection']);
|
|
75
81
|
headers.push('Accept: ' + options['accept']);
|
|
76
82
|
headers.push('Accept-Language: ' + options['acceptLanguage']);
|
|
77
83
|
headers.push('User-Agent: ' + options['userAgent']);
|
|
78
84
|
headers.push('Cache-Control: ' + options['cacheControl']);
|
|
79
85
|
headers.push('Proxy-Connection: ' + options['proxyConnection']);
|
|
80
|
-
if (options
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
if (options.referer) {
|
|
87
|
+
headers.push('Referer: ' + options.referer);
|
|
88
|
+
}
|
|
89
|
+
if (!options.noDeflate) {
|
|
90
|
+
headers.push('Accept-Encoding: gzip, deflate');
|
|
91
|
+
}
|
|
92
|
+
if (options.xhr) {
|
|
93
|
+
headers.push('X-Requested-With: XMLHttpRequest');
|
|
94
|
+
}
|
|
95
|
+
if (options.origin) {
|
|
96
|
+
headers.push('Origin: ' + options.origin);
|
|
97
|
+
}
|
|
98
|
+
if (options.authBasic) {
|
|
99
|
+
headers.push('Authorization: Basic ' + (new Buffer(options.authBasic)).toString('base64'));
|
|
100
|
+
}
|
|
101
|
+
if (options.authBearer) {
|
|
102
|
+
headers.push('Authorization: Bearer ' + options.authBearer);
|
|
103
|
+
}
|
|
83
104
|
if (options['headers']) {
|
|
84
105
|
for (let i = 0; i < options['headers'].length; i++) {
|
|
85
106
|
headers.push(options['headers'][i]);
|
|
@@ -113,7 +134,7 @@ let DvBrowser = function (_config) {
|
|
|
113
134
|
curl.setOpt(Curl.option.FOLLOWLOCATION, options.allowRedirect);
|
|
114
135
|
curl.setOpt(Curl.option.SSL_VERIFYHOST, false);
|
|
115
136
|
curl.setOpt(Curl.option.SSL_VERIFYPEER, false);
|
|
116
|
-
if (!options
|
|
137
|
+
if (!options.noDeflate) {
|
|
117
138
|
curl.setOpt(Curl.option.ACCEPT_ENCODING, 'gzip');
|
|
118
139
|
}
|
|
119
140
|
if (options.httpProxy) {
|