1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 * This module consolidates various code and data update requests, so flags
9 * can be set, Telemetry collected, etc. in a central place.
12 const { Log } = ChromeUtils.import("resource://gre/modules/Log.jsm");
13 const { XPCOMUtils } = ChromeUtils.import(
14 "resource://gre/modules/XPCOMUtils.jsm"
16 XPCOMUtils.defineLazyGlobalGetters(this, ["XMLHttpRequest"]);
18 var EXPORTED_SYMBOLS = ["ServiceRequest"];
20 const logger = Log.repository.getLogger("ServiceRequest");
21 logger.level = Log.Level.Debug;
22 logger.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter()));
25 * ServiceRequest is intended to be a drop-in replacement for current users
28 * @param {Object} options - Options for underlying XHR, e.g. { mozAnon: bool }
30 class ServiceRequest extends XMLHttpRequest {
31 constructor(options) {
35 * Opens an XMLHttpRequest, and sets the NSS "beConservative" flag.
36 * Requests are always async.
38 * @param {String} method - HTTP method to use, e.g. "GET".
39 * @param {String} url - URL to open.
40 * @param {Object} options - Additional options (reserved for future use).
42 open(method, url, options) {
43 super.open(method, url, true);
45 // Disable cutting edge features, like TLS 1.3, where middleboxes might brick us
46 if (super.channel instanceof Ci.nsIHttpChannelInternal) {
47 super.channel.QueryInterface(
48 Ci.nsIHttpChannelInternal
49 ).beConservative = true;