Create an XHR object
@private
@param {type} [local] If set to true, the XHR will be file: protocol
compatible if possible (but may raise a warning in the browser).
@returns {XMLHttpRequest}
339412
function( local ) {
            // IE11 does not support window.ActiveXObject so we just try to
            // create one to see if it is supported.
            // See: http://msdn.microsoft.com/en-us/library/ie/dn423948%28v=vs.85%29.aspx
            var supportActiveX;
            try {
                /* global ActiveXObject:true */
                supportActiveX = !!new ActiveXObject( "Microsoft.XMLHTTP" );
            } catch( e ) {
                supportActiveX = false;
            }

            if ( supportActiveX ) {
                if ( window.XMLHttpRequest ) {
                    $.createAjaxRequest = function( local ) {
                        if ( local ) {
                            return new ActiveXObject( "Microsoft.XMLHTTP" );
                        }
                        return new XMLHttpRequest();
                    };
                } else {
                    $.createAjaxRequest = function() {
                        return new ActiveXObject( "Microsoft.XMLHTTP" );
                    };
                }
            } else if ( window.XMLHttpRequest ) {
                $.createAjaxRequest = function() {
                    return new XMLHttpRequest();
                };
            } else {
                throw new Error( "Browser doesn't support XMLHttpRequest." );
            }
            return $.createAjaxRequest( local );
        }
303666
def local_open(url):
    """"""
    scheme, server, path, param, query, frag = urllib.parse.urlparse(url)
    filename = urllib.request.url2pathname(path)
    if os.path.isfile(filename):
        return urllib.request.urlopen(url)
    elif path.endswith('/') and os.path.isdir(filename):
        files = []
        for f in os.listdir(filename):
            filepath = os.path.join(filename, f)
            if f == 'index.html':
                with open(filepath, 'r') as fp:
                    body = fp.read()
                break
            elif os.path.isdir(filepath):
                f += '/'
            files.append('<a href="{name}">{name}</a>'.format(name=f))
        else:
            tmpl = (
                "<html><head><title>{url}</title>"
                "</head><body>{files}</body></html>")
            body = tmpl.format(url=url, files='\n'.join(files))
        status, message = 200, "OK"
    else:
        status, message, body = 404, "Path not found", "Not found"

    headers = {'content-type': 'text/html'}
    body_stream = six.StringIO(body)
    return urllib.error.HTTPError(url, status, message, headers, body_stream)
376116
function( url, cb ) {
		var xhr = new window.XMLHttpRequest();
		if ( "withCredentials" in xhr ) {
			xhr.open( "GET", url, true );
		} else if ( typeof window.XDomainRequest !== "undefined" ) { //IE
			xhr = new window.XDomainRequest();
			xhr.open( "GET", url );
		}
		if( cb ){
			xhr.onload = cb;
		}
		xhr.send();
		return xhr;
	}
135043
function () {

	var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];

	function xhr () {
		if (typeof XMLHttpRequest !== "undefined") {
			// rewrite the getXhr method to always return the native implementation
			xhr = function () { return new XMLHttpRequest(); };
		}
		else {
			// keep trying progIds until we find the correct one, then rewrite the getXhr method
			// to always return that one.
			var noXhr = xhr = function () {
					throw new Error("getXhr(): XMLHttpRequest not available");
				};
			while (progIds.length > 0 && xhr === noXhr) (function (id) {
				try {
					new ActiveXObject(id);
					xhr = function () { return new ActiveXObject(id); };
				}
				catch (ex) {}
			}(progIds.shift()));
		}
		return xhr();
	}

	function fetchText (url, callback, errback) {
		var x = xhr();
		x.open('GET', url, true);
		x.onreadystatechange = function (e) {
			if (x.readyState === 4) {
				if (x.status < 400) {
					callback(x.responseText);
				}
				else {
					errback(new Error('fetchText() failed. status: ' + x.statusText));
				}
			}
		};
		x.send(null);
	}

	function error (ex) {
		throw ex;
	}

	return {

//		'normalize': function (resourceId, toAbsId) {
//			// remove options
//			return resourceId ? toAbsId(resourceId.split("!")[0]) : resourceId;
//		},

		load: function (resourceName, req, callback, config) {
			// remove suffixes (future)
			// get the text
			fetchText(req['toUrl'](resourceName), callback, callback['error'] || error);
		},

		'plugin-builder': './builder/text'

	};

}
174674
function createServer () {

    // Create server

    var server = express.createServer();

    // Configure Server

    server.configure(function () {

        // Built-in

        server.use(express.methodOverride());                           // Allow method override using _method form parameter
        server.use(express.bodyDecoder()); 	                            // Parse application/x-www-form-urlencoded
        server.use(express.staticProvider(__dirname + '/files'));       // Serve client documents in local directory

        // Local

        server.use(setResponseHeader());                                // Set default response headers for CORS
        server.use(logConsole());                                       // Display incoming requests

        // Authentication

        server.use(auth([auth.Mac({ realm: "Example",                   // Set realm, typically a domain name or application name
                                    getTokenAttributes: getToken,       // Function used to fetch the access token record, typically from a database
                                    // hostHeader: 'x-forwarded-host',  // Needed when running behind a proxy such as Apache2
                                    // isHTTPS: true,                   // Uncomment for HTTPS
                                    checkNonce: nonceCheck,             // Optional nonce checking function
                                    bodyHashMode: "require" })]));      // Require body hash validation for all non GET/HEAD/OPTIONS requests
    });

    // Setup generic OPTIONS route

    server.options(/.+/, function (req, res) {

        res.send(' ');
    });

    return server;
}
1169328
function isCrossOriginXhrSupported() {
        if (window.XMLHttpRequest) {
            var xhr = qq.createXhrInstance();

            //Commonly accepted test for XHR CORS support.
            return xhr.withCredentials !== undefined;
        }

        return false;
    }
1028900
function loadSyncXHR(oModule) {
		var xhr = new XMLHttpRequest();

		function enrichXHRError(error) {
			error = error || ensureStacktrace(new Error(xhr.status + " - " + xhr.statusText));
			error.status = xhr.status;
			error.statusText = xhr.statusText;
			error.loadError = true;
			return error;
		}

		xhr.addEventListener('load', function(e) {
			// File protocol (file://) always has status code 0
			if ( xhr.status === 200 || xhr.status === 0 ) {
				oModule.state = LOADED;
				oModule.data = xhr.responseText;
			} else {
				oModule.error = enrichXHRError();
			}
		});
		// Note: according to whatwg spec, error event doesn't fire for sync send(), instead an error is thrown
		// we register a handler, in case a browser doesn't follow the spec
		xhr.addEventListener('error', function(e) {
			oModule.error = enrichXHRError();
		});
		xhr.open('GET', oModule.url, false);
		try {
			xhr.send();
		} catch (error) {
			oModule.error = enrichXHRError(error);
		}
	}
1039623
async function loadLocalFile() {
    // Imports a local file into a table.

    // Create a client
    const bigqueryClient = new BigQuery();

    // Load data from a local file into the table
    const [job] = await bigqueryClient
      .dataset(datasetId)
      .table(tableId)
      .load(filename);

    console.log(`Job ${job.id} completed.`);

    // Check the job's status for errors
    const errors = job.status.errors;
    if (errors && errors.length > 0) {
      throw errors;
    }
  }
275660
public static function local()
    {
        //====================================================================//
        // Initialize Local Core Management Class
        if (isset(self::core()->localcore)) {
            return self::core()->localcore;
        }
        //====================================================================//
        // Verify Local Core Class Exist & is Valid
        if (!self::validate()->isValidLocalClass()) {
            throw new Exception('You requested access to Local Class, but it is Invalid...');
        }
        //====================================================================//
        // Initialize Class
        self::core()->localcore = new Local();
        //====================================================================//
        //  Load Translation File
        self::translator()->load('local');
        //====================================================================//
        // Load Local Includes
        self::core()->localcore->Includes();
        //====================================================================//
        // Return Local Class
        return self::core()->localcore;
    }
7772
function XMLHttpRequest() {
  EventTarget.call(this, events);

  this.readyState;

  if (support.xhr.timeout) {
    this.timeout = 0;
  }

  if (support.xhr.cors) {
    this.withCredentials = false;
  }

  this.upload;
  this.responseType = '';
  this.responseText = '';
  this.responseXML = null;
  this.readyState = states.UNSENT;

  if (support.xhr.response) {
    this.response = '';
  }

  if (support.xhr.responseURL) {
    this.responseURL = '';
  }

  this.status = 0;
  this.statusText = '';
}
968505
function inlineLocalContent() {
      // inline local javascript
      filecontent = filecontent.replace(sre, function(matched, src) {
        if (!incfiles[src]) {
          return matched; // This file wasn't available
        }
        return matched.replace(srcre, '') + '\n' + incfiles[src];
      });
      // now inline local css
      filecontent = filecontent.replace(cre, function(matched, src) {
        var tag;
        if (!incfiles[src]) {
          return matched;
        }
        if (matched.toLowerCase().search('stylesheet') === -1) {
          return matched;
        }
        tag = matched.replace(hrefre, ''); // remove href attribute
        tag = tag.replace(crerel, ''); // remove rel attribute
        tag = tag.replace(cretag, '<style'); // change link to style
        tag = tag.replace(creend, '>'); // remove possible self-closing in style tag
        return tag + '\n' + incfiles[src] + '\n</style>';
      });
      //console.log(filecontent);
      resolve(filecontent);
    }
1274812
function XHR(opts){
  Polling.call(this, opts);

  if (global.location) {
    var isSSL = 'https:' == location.protocol;
    var port = location.port;

    // some user agents have empty `location.port`
    if (Number(port) !== port) {
      port = isSSL ? 443 : 80;
    }

    this.xd = opts.hostname != global.location.hostname ||
      port != opts.port;
  }
}
675117
function XHRProxy(options) { // @arg Object = {} - { verbose }
                             // @options.verbose Boolean = false
//{@dev
    $valid($type(options, "Object|omit"), XHRProxy, "options");
//}@dev

    options = options || {};
    this._verbose = options["verbose"] || false;

//{@dev
    $valid($type(options.verbose, "Boolean|omit"), XHRProxy, "options.verbose");
//}@dev

    this._event = new WMEvent()["register"](ALLOW_XHR_EVENTS);
    this._xhr = null;
    this._lv = FUNCTION_LEVEL_0;

    if (global["XMLHttpRequest"]) { // _runOnBrowser
        this._lv = FUNCTION_LEVEL_1;
        this._xhr = new XMLHttpRequest();

        if ("onload"          in this._xhr &&
            "responseType"    in this._xhr &&
            "withCredentials" in this._xhr) {
            this._lv = FUNCTION_LEVEL_2;
        }
    } else { // _runOnNode -> simulate XMLHttpRequest Object
        this._xhr = {
            "readyState":       READY_STATE_UNSENT,
            // --- request ---
            "method":           "",     // "GET" or "POST"
            "url":              "",
            "async":            true,
            "auth":             "",     // "" or "user:password"
            "requestHeader":    {},     // { header: value, ... }
            // --- response ---
            "response":         null,
            "responseText":     "",
            "responseXML":      null,
            "responseHeaders":  {},     // { header: value, ... }
            "status":           0,
            "statusText":       "",
            "upload":           null,
            "withCredentials":  false
        };
    }

//{@dev
    if (this._verbose) {
        console.log("XMLHttpRequest Level is " + this._lv);
    }
//}@dev

    this._lastRequestURL = "";
    this._lastReadyState = READY_STATE_UNSENT;

    // setup property getter and setter.
    Object.defineProperties(this, {
        "readyState":     { "get": getReadyState                                },
        "response":       { "get": getResponse                                  },
        "responseText":   { "get": getResponseText                              },
        "responseType":   { "get": getResponseType,   "set": setResponseType    },
        "responseXML":    { "get": getResponseXML                               },
        "status":         { "get": getStatus                                    },
        "statusText":     { "get": getStatusText                                },
        "upload":         { "get": getUpload,         "set": setUpload          },
        "withCredentials":{ "get": getWithCredentials,"set": setWithCredentials }
    });
}
710177
function(type, url, data, options, callback) {
  /* Make a request to the given URL, and call:
   *  callback(http_code, headers, data);
   *
   * Arguments:
   *  - options: hash, with the possible members:
   *    - emulate_browser: Add some firefox headers if set to True
   *    - additional_headers: hash containing some headers to add / redefine.
   */
  var body;
  var purl = URL.parse(url);
  var qs = purl.query || '';
  var secure = purl.protocol == 'https:';
  var default_port = secure && 443 || 80;
  var client = http.createClient(purl.port || default_port, purl.hostname, secure);
  client.addListener('error', function(err) {
    console.log('Error in nodetk web client.');
    console.log(err.message);
    console.log(err.stack);
  });
  var headers = {
    'host': purl.hostname,
  };
  extend(headers, options.additional_headers || {});
  if(options.emulate_browser) extend(headers, {
    'User-Agent': 'Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.1.9) Gecko/20100401 Ubuntu/9.10 (karmic) Firefox/3.5.9',
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Accept-Language': 'fr-fr,fr;q=0.8,en;q=0.5,en-us;q=0.3',
    //'Accept-Encoding': 'gzip,deflate',
  });
  if(type == 'POST' || type == 'PUT' || type == "DELETE") {
    body = data && querystring.stringify(data) || "";
    headers['content-type'] = 'application/x-www-form-urlencoded';
    headers['content-length'] = Buffer.byteLength(body);
  }
  else if (data) {
    if(qs) qs += '&';
    qs += querystring.stringify(data);
  }
  var request = client.request(type, purl.pathname +'?'+ qs, headers);
  if(body) {
    request.write(body, 'utf8');
  }
  request.end();
  var data = '';
  request.on('response', function(response) {
    response.setEncoding('utf8');
    response.on('data', function(chunk) {
      data += chunk;
    });
    response.on('end', function() {
      callback(response.statusCode, response.headers, data);
    });
  });
}
1302902
function(xhr) {
    var response = {
        headers: {},
        statusCode: xhr.status
    };

    var headerPairs = xhr.getAllResponseHeaders().split('\u000d\u000a');
    for (var i = 0; i < headerPairs.length; i++) {
        var headerPair = headerPairs[i],
            index = headerPair.indexOf('\u003a\u0020');

        if (index > 0) {
            var key = headerPair.substring(0, index);
            var val = headerPair.substring(index + 2);
            response.headers[key.toLowerCase()] = val;
        }
    }

    return response;
}
704858
function () {
				var that = this;

				var oInternalRulesPromise = new Promise(function (resolve) {

					if (that.bCanLoadInternalRules !== null) {
						resolve(that.bCanLoadInternalRules);

						return;
					}


					jQuery.ajax({
						type: "HEAD",
						url: sInternalPingFilePath,
						success: function () {
							that.bCanLoadInternalRules = true;
							resolve(that.bCanLoadInternalRules);
						},
						error: function() {
							that.bCanLoadInternalRules = false;
							resolve(that.bCanLoadInternalRules);
						}
					});
				});

				return oInternalRulesPromise;
			}
575975
function xhr (url, responseType) {
  return new Promise((resolve, reject) => {
    var x = new XMLHttpRequest();

    if (responseType)
      x.responseType = responseType;

    x.open('get', url, true);

    x.onreadystatechange = function() {
      if (x.readyState === 4) { // `DONE`
        if (x.status === 200) {
          resolve(x.responseText);
        } else {
          reject(x.status);
        }
      }
    };
    x.send();
  });
}