Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 "te": true, | 317 "te": true, |
318 "trailer": true, | 318 "trailer": true, |
319 "transfer-encoding": true, | 319 "transfer-encoding": true, |
320 "upgrade": true, | 320 "upgrade": true, |
321 "via": true, | 321 "via": true, |
322 }, | 322 }, |
323 _forbiddenRequestHeadersRe: new RegExp("^(Proxy|Sec)-", "i"), | 323 _forbiddenRequestHeadersRe: new RegExp("^(Proxy|Sec)-", "i"), |
324 | 324 |
325 _isRequestHeaderAllowed: function(header) | 325 _isRequestHeaderAllowed: function(header) |
326 { | 326 { |
327 if (this._forbiddenRequestHeaders[header.toLowerCase()] !== undefined) { | 327 if (this._forbiddenRequestHeaders.hasOwnProperty(header.toLowerCase())) |
sergei
2017/03/02 22:25:31
Actually it's not according to our coding style, s
hub
2017/03/02 23:30:12
Acknowledged.
| |
328 return false; | 328 return false; |
329 } | 329 if (header.match(this._forbiddenRequestHeadersRe)) |
330 if (header.match(this._forbiddenRequestHeadersRe)) { | |
331 return false; | 330 return false; |
332 } | 331 |
333 return true; | 332 return true; |
334 }, | 333 }, |
335 | 334 |
336 addEventListener: function(eventName, handler, capture) | 335 addEventListener: function(eventName, handler, capture) |
337 { | 336 { |
338 var list; | 337 var list; |
339 if (eventName == "load") | 338 if (eventName == "load") |
340 list = this._loadHandlers; | 339 list = this._loadHandlers; |
341 else if (eventName == "error") | 340 else if (eventName == "error") |
342 list = this._errorHandlers; | 341 list = this._errorHandlers; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 | 408 |
410 overrideMimeType: function(mime) | 409 overrideMimeType: function(mime) |
411 { | 410 { |
412 }, | 411 }, |
413 | 412 |
414 setRequestHeader: function(name, value) | 413 setRequestHeader: function(name, value) |
415 { | 414 { |
416 if (this.readyState > 1) | 415 if (this.readyState > 1) |
417 throw new Error("Cannot set request header after sending"); | 416 throw new Error("Cannot set request header after sending"); |
418 | 417 |
419 if (this._isRequestHeaderAllowed(name)) { | 418 if (this._isRequestHeaderAllowed(name)) |
420 this._requestHeaders[name] = value; | 419 this._requestHeaders[name] = value; |
421 } else { | 420 else |
422 console.warning("Attempt to set a forbidden header was denied: " + name); | 421 console.warn("Attempt to set a forbidden header was denied: " + name); |
sergei
2017/03/02 22:25:31
the name of the method should be "warn"
hub
2017/03/02 23:30:12
Looks like my testing has failed here. Will defini
| |
423 } | |
424 }, | 422 }, |
425 | 423 |
426 getResponseHeader: function(name) | 424 getResponseHeader: function(name) |
427 { | 425 { |
428 name = name.toLowerCase(); | 426 name = name.toLowerCase(); |
429 if (!this._responseHeaders || !this._responseHeaders.hasOwnProperty(name)) | 427 if (!this._responseHeaders || !this._responseHeaders.hasOwnProperty(name)) |
430 return null; | 428 return null; |
431 else | 429 else |
432 return this._responseHeaders[name]; | 430 return this._responseHeaders[name]; |
433 }, | 431 }, |
434 | 432 |
435 channel: | 433 channel: |
436 { | 434 { |
437 status: -1, | 435 status: -1, |
438 notificationCallbacks: {}, | 436 notificationCallbacks: {}, |
439 loadFlags: 0, | 437 loadFlags: 0, |
440 INHIBIT_CACHING: 0, | 438 INHIBIT_CACHING: 0, |
441 VALIDATE_ALWAYS: 0, | 439 VALIDATE_ALWAYS: 0, |
442 QueryInterface: function() | 440 QueryInterface: function() |
443 { | 441 { |
444 return this; | 442 return this; |
445 } | 443 } |
446 } | 444 } |
447 }; | 445 }; |
LEFT | RIGHT |