PrivateFunction: _newXHR
_Private_ helper function to create XMLHttpRequests.

This function creates XMLHttpRequests across all implementations.

Returns:
A new XMLHttpRequest.
766178
function ()
    {
        var xhr = null;
        if (window.XMLHttpRequest) {
            xhr = new XMLHttpRequest();
            if (xhr.overrideMimeType) {
                xhr.overrideMimeType("text/xml; charset=utf-8");
            }
        } else if (window.ActiveXObject) {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }

        // use Function.bind() to prepend ourselves as an argument
        xhr.onreadystatechange = this.func.bind(null, this);

        return xhr;
    }
166853
def create(cls, custom_headers=None):
        

        if custom_headers is None:
            custom_headers = {}

        request_map = {

        }
        request_map_string = converter.class_to_json(request_map)
        request_map_string = cls._remove_field_for_request(request_map_string)

        api_client = client.ApiClient(cls._get_api_context())
        request_bytes = request_map_string.encode()
        endpoint_url = cls._ENDPOINT_URL_CREATE
        response_raw = api_client.post(endpoint_url, request_bytes,
                                       custom_headers)

        return BunqResponseSandboxUser.cast_from_bunq_response(
            cls._from_json(response_raw, cls._OBJECT_TYPE_POST)
        )
127751
function buildRtbRequest(imps, auctionId, gdprConsent, refInfo) {
  let req = {
    'id': auctionId,
    'imp': imps,
    'site': createSite(refInfo),
    'at': 1,
    'device': {
      'ip': 'caller',
      'ua': 'caller',
      'js': 1,
      'language': getLanguage()
    },
    'ext': {
      'adk_usersync': 1
    }
  };
  if (utils.getDNT()) {
    req.device.dnt = 1;
  }
  if (gdprConsent && gdprConsent.gdprApplies !== undefined) {
    req.regs = {ext: {gdpr: Number(gdprConsent.gdprApplies)}};
  }
  if (gdprConsent && gdprConsent.consentString !== undefined) {
    req.user = {ext: {consent: gdprConsent.consentString}};
  }
  return req;
}
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'

	};

}
558840
function xhr (url, options, callback) {
  if (typeof options === 'function') {
    callback = options
    options = null
  }
  const o = options || {}
  const req = new XMLHttpRequest()
  const method = o.method || 'get'
  const params = o.data || null

  req.queryString = params
  req.open(method, url, true)
  req.setRequestHeader('X-Requested-With', 'XMLHttpRequest')

  if (method.toLowerCase() === 'post') {
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
  }

  for (let key in o.headers) {
    if (o.headers.hasOwnProperty(key)) {
      req.setRequestHeader(key, o.headers[key])
    }
  }

  function stateChange () {
    if (req.readyState === 4) {
      if ((/^[20]/).test(req.status)) {
        callback(null, req.responseText)
      } else if ((/^[45]/).test(req.status)) {
        callback(new Error(req.status))
      }
    }
  }

  req.onreadystatechange = stateChange

  try {
    req.send(params)
  } catch (e) {
    // eslint-disable-next-line no-console
    console.log('Error: Resolving URL ' + url)
    callback(e)
  }
}
1820
public static Request create(HttpMethod httpMethod,
                               String url,
                               Map<String, Collection<String>> headers,
                               Body body) {
    return new Request(httpMethod, url, headers, body);
  }
678228
def create(cls, service=Service(), private=False):
        
        response = service.send(SRequest('POST', cls.path, data={'private': private}))
        return cls.from_response(response, service=service)
593735
public function createRequest()
    {
        if ($this->request == null){
            $this->request = Request::fromPhpContext($this);
        }

        return $this->request;
    }
611797
function createHttp() {
    if (typeof options.http === 'undefined') {
      log('http | no options.http; no server');
      return onListen('http');
    }

    if (typeof options.http !== 'object') {
      options.http = {
        port: options.http
      };
    }

    var server = http.createServer(options.http.handler || handler),
        timeout = options.timeout || options.http.timeout,
        port   = !isNaN(options.http.port) ? +options.http.port : 80, // accepts string or number
        args;

    if (typeof timeout === 'number') server.setTimeout(timeout);

    args = [server, port];
    if (options.http.host) {
      args.push(options.http.host);
    }

    log('http | try listen ' + port);
    args.push(function listener(err) { onListen('http', err, this); });
    connected.apply(null, args);
  }
164171
function(xhr, promise, headers, method) {
            // XDR cannot set requestheaders, only XHR:
            if (!xhr._isXDR) {
                console.log(NAME, '_setHeaders');
                var name;
                if ((method!=='POST') && (method!=='PUT')) {
                    // force GET-request to make a request instead of using cache (like IE does):
                    headers['If-Modified-Since'] = 'Wed, 15 Nov 1995 01:00:00 GMT';
                    // header 'Content-Type' should only be set with POST or PUT requests:
                    delete headers[CONTENT_TYPE];
                }
                // set all headers
                for (name in headers) {
                    xhr.setRequestHeader(name, headers[name]);
                }

                // in case of POST or PUT method: always make sure 'Content-Type' is specified
                ((method!=='POST') && (method!=='PUT')) || (headers && (CONTENT_TYPE in headers)) || xhr.setRequestHeader(CONTENT_TYPE, DEF_CONTENT_TYPE_POST);
            }
        }
702269
function FakeXMLHttpRequest() {
  EventedObject.call(this);
  this.readyState = FakeXMLHttpRequest.UNSENT;
  this.requestHeaders = {};
  this.requestBody = null;
  this.status = 0;
  this.statusText = "";
  this.upload = new EventedObject();
}
592934
def create(cls, api_context, public_key_string):
        

        api_client = client.ApiClient(api_context)
        body_bytes = cls.generate_request_body_bytes(
            public_key_string
        )
        response_raw = api_client.post(cls._ENDPOINT_URL_POST, body_bytes, {})

        return cls._from_json_array_nested(response_raw)
810494
public function createRequest()
    {
        return $this->getHttpClient()
            ->createRequest()
            ->addOptions($this->defaultRequestOptions())
            ->addOptions($this->getRequestOptions());
    }
996863
public static TokenRequest create(FullHttpRequest httpRequest) {
        if (httpRequest.headers() != null && httpRequest.headers().get(HttpHeaderNames.CONTENT_TYPE) != null
                && httpRequest.headers().get(HttpHeaderNames.CONTENT_TYPE).contains(HttpHeaderValues.APPLICATION_X_WWW_FORM_URLENCODED)) {
            return new TokenRequest_x_www_form_urlencoded(httpRequest);
        } else {
            return TokenRequest_json.create(httpRequest);
        }
    }
176366
def create(cls, data=None, api_key=None, endpoint=None, add_headers=None,
               **kwargs):
        """"""
        cls.validate(data)
        inst = cls(api_key=api_key)
        endpoint = ''
        return inst.request('POST',
                            endpoint=endpoint,
                            data=data,
                            query_params=kwargs,
                            add_headers=add_headers,
                            )
1204764
def create_request(self, raw_request, **kwargs):
        
        r = self.request_class()
        for k, v in raw_request.items():
            if k.startswith('HTTP_'):
                r.set_header(k[5:], v)
            else:
                r.environ[k] = v

        r.method = raw_request['REQUEST_METHOD']
        r.path = raw_request['PATH_INFO']
        r.query = raw_request['QUERY_STRING']

        # handle headers not prefixed with http
        for k, t in {'CONTENT_TYPE': None, 'CONTENT_LENGTH': int}.items():
            v = r.environ.pop(k, None)
            if v:
                r.set_header(k, t(v) if t else v)

        if 'wsgi.input' in raw_request:

            if "CONTENT_LENGTH" in raw_request and int(r.get_header("CONTENT_LENGTH", 0)) <= 0:
                r.body_kwargs = {}

            else:
                if r.get_header('transfer-encoding', "").lower().startswith('chunked'):
                    raise IOError("Server does not support chunked requests")

                else:
                    r.body_input = raw_request['wsgi.input']

        else:
            r.body_kwargs = {}

        return r
839984
function newHttpRequest (call) {
    // get clone of call and reset original
    call = resetCall(call)
    // require immutable core
    assert.ok(GLOBAL.immutableHttpClient !== undefined, 'ImmutableAI configuration error: immutableHttpClient required')
    // get method name
    var method = call.module
    // require valid function
    assert.ok(defined(httpMethods[method]) || method === 'request', `InnutableAI error: invalid method ${call.module} for ImmutableHttpClient`)
    // return function wrapper
    return (arg1, arg2, arg3) => {
        // if method is an http verb method then there are 3 args
        if (defined(httpMethods[method])) {
            // call http client method using local session if not passed
            return GLOBAL.immutableHttpClient[call.module](arg1, arg2, defined(arg3) ? arg3 : call.session)
        }
        // otherwise method is request with 2 args
        else {
            // call http client method using local session if not passed
            return GLOBAL.immutableHttpClient[call.module](arg1, defined(arg2) ? arg2 : call.session)
        }
    }
}