|
29 | 29 | }; |
30 | 30 |
|
31 | 31 | // http/web object detection |
32 | | - HTTPObject = ['MSXML2.SERVERXMLHTTP.6.0', 'MSXML2.SERVERXMLHTTP.3.0', 'MSXML2.SERVERXMLHTTP'].find(function (xhr) { |
| 32 | + HTTPObject = ['WinHttp.WinHttpRequest.5.1'].find(function (whr) { |
33 | 33 | try { |
34 | | - return new ActiveXObject(xhr), xhr; |
| 34 | + return new ActiveXObject(whr), whr; |
35 | 35 | } catch (ignore) {} |
36 | 36 | }); |
37 | 37 |
|
|
145 | 145 | this._json = json; |
146 | 146 | } |
147 | 147 | this._state = parent._state || 'init'; |
148 | | - this._type = parent._type || 'text'; |
| 148 | + this._type = parent._type || 'text'; |
149 | 149 | this._parse = parent._parse === false ? false : true; |
150 | 150 | this._error = parent._error || false; |
151 | 151 | this._input = parent._input; |
152 | | - // (slv) Added 'insecure' |
153 | 152 | this._http = parent._http || { |
154 | 153 | method: 'GET', |
155 | 154 | url: '', |
156 | 155 | headers: [], |
157 | | - insecure: false |
| 156 | + insecure: false, |
| 157 | + redirects: true |
158 | 158 | }; |
159 | 159 | } |
160 | 160 |
|
|
246 | 246 | request = new ActiveXObject(HTTPObject); |
247 | 247 | this._http.response = request; |
248 | 248 |
|
249 | | - // Option to ignore all ssl certificate errors |
250 | | - // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms763811(v=vs.85) |
251 | | - // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms753798(v=vs.85) |
252 | | - if (this._http.insecure === true) { |
253 | | - request.setOption(2, 13056); |
| 249 | + // If indicated, ignore all ssl certificate errors |
| 250 | + if (this._http.insecure) { |
| 251 | + request.Options(4) = 13056; |
| 252 | + } |
| 253 | + |
| 254 | + // If indicated, do not follow redirects |
| 255 | + if (!this._http.redirects) { |
| 256 | + request.Options(6) = false; |
254 | 257 | } |
255 | 258 |
|
256 | 259 | // initialize the request |
|
566 | 569 |
|
567 | 570 | root.JSONInstance = JSONInstance; |
568 | 571 |
|
569 | | - root.JSONCreate = function(type, source, parse, insecure) { |
| 572 | + root.JSONCreate = function(type, source, parse, insecure, redirects) { |
570 | 573 | var self = new JSONInstance(); |
571 | 574 | self._state = 'init'; |
572 | 575 | self._type = (type || 'text').toLowerCase(); |
|
580 | 583 | self._state = 'http_pending'; |
581 | 584 | self._http.url = source; |
582 | 585 | self._http.insecure = insecure; |
| 586 | + self._http.redirects = redirects; |
| 587 | + |
583 | 588 | } else { |
584 | 589 | self._state = 'parse_pending'; |
585 | 590 | self._input = source; |
|
0 commit comments