dv-browser 2.5.2 → 2.5.3

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.
Files changed (2) hide show
  1. package/index.js +5 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -17,11 +17,11 @@ let DvBrowser = function (_config) {
17
17
  cacheControl: 'max-age=0',
18
18
  connection: 'close',
19
19
  proxyConnection: 'close',
20
+ xhr: false,
20
21
  }, _config);
21
22
 
22
23
  const cookiejar = new CookieJar(null);
23
24
 
24
- this.getProxy = function () { return config.httpProxy; };
25
25
  this.setCookie = function (cookie, url, options) { cookiejar.setCookieSync(cookie, url, options); };
26
26
  this.getCookie = function (key, url) {
27
27
  let cookies = cookiejar.getCookiesSync(url);
@@ -67,11 +67,10 @@ let DvBrowser = function (_config) {
67
67
  if (cookieString) {
68
68
  headers.push('Cookie: ' + cookieString);
69
69
  }
70
- if (options['contentType']) {
71
- headers.push('Content-Type: ' + options['contentType']);
72
- } else if (method === 'POST') {
73
- headers.push('Content-Type: application/x-www-form-urlencoded');
70
+ if (!options.contentType && options.postData) {
71
+ options.contentType = 'application/x-www-form-urlencoded';
74
72
  }
73
+ headers.push('Content-Type: ' + options.contentType);
75
74
  headers.push('Connection: ' + options['connection']);
76
75
  headers.push('Accept: ' + options['accept']);
77
76
  headers.push('Accept-Language: ' + options['acceptLanguage']);
@@ -80,6 +79,7 @@ let DvBrowser = function (_config) {
80
79
  headers.push('Proxy-Connection: ' + options['proxyConnection']);
81
80
  if (options['referer']) headers.push('Referer: ' + options['referer']);
82
81
  if (!options['noDeflate']) headers.push('Accept-Encoding: gzip, deflate');
82
+ if (options.xhr) headers.push('X-Requested-With: XMLHttpRequest');
83
83
  if (options['headers']) {
84
84
  for (let i = 0; i < options['headers'].length; i++) {
85
85
  headers.push(options['headers'][i]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dv-browser",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {