diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /toolkit/modules/ServiceRequest.jsm | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/modules/ServiceRequest.jsm')
-rw-r--r-- | toolkit/modules/ServiceRequest.jsm | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/toolkit/modules/ServiceRequest.jsm b/toolkit/modules/ServiceRequest.jsm new file mode 100644 index 000000000..92afec113 --- /dev/null +++ b/toolkit/modules/ServiceRequest.jsm @@ -0,0 +1,49 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components; + +/** + * This module consolidates various code and data update requests, so flags + * can be set, Telemetry collected, etc. in a central place. + */ + +Cu.import("resource://gre/modules/Log.jsm"); +Cu.importGlobalProperties(["XMLHttpRequest"]); + +this.EXPORTED_SYMBOLS = [ "ServiceRequest" ]; + +const logger = Log.repository.getLogger("ServiceRequest"); +logger.level = Log.Level.Debug; +logger.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter())); + +/** + * ServiceRequest is intended to be a drop-in replacement for current users + * of XMLHttpRequest. + * + * @param {Object} options - Options for underlying XHR, e.g. { mozAnon: bool } + */ +class ServiceRequest extends XMLHttpRequest { + constructor(options) { + super(options); + } + /** + * Opens an XMLHttpRequest, and sets the NSS "beConservative" flag. + * Requests are always async. + * + * @param {String} method - HTTP method to use, e.g. "GET". + * @param {String} url - URL to open. + * @param {Object} options - Additional options (reserved for future use). + */ + open(method, url, options) { + super.open(method, url, true); + + // Disable cutting edge features, like TLS 1.3, where middleboxes might brick us + if (super.channel instanceof Ci.nsIHttpChannelInternal) { + super.channel.QueryInterface(Ci.nsIHttpChannelInternal).beConservative = true; + } + } +} |