recursal/MDN huggingface dataset:
XMLHttpRequest: open() method
=============================

 The `XMLHttpRequest` method **`open()`**
 initializes a newly-created request, or re-initializes an existing one.


**Note:** Calling this method for an already active request
 (one for which `open()` has already been called) is the equivalent of calling
 `abort()`.


Syntax
------


```js
open(method, url)
open(method, url, async)
open(method, url, async, user)
open(method, url, async, user, password)
```

### Parameters

`method`

 The HTTP request method to use, such as
 `"GET"`, `"POST"`, `"PUT"`, `"DELETE"`,
 etc. Ignored for non-HTTP(S) URLs.


`url`

A string or any other object with a stringifier — including a `URL` object — that provides the URL of the resource to send the request to.

`async` Optional

 An optional Boolean parameter, defaulting to `true`, indicating whether
 or not to perform the operation asynchronously. If this value is `false`,
 the `send()` method does not return until the response is received. If
 `true`, notification of a completed transaction is provided using event
 listeners. This *must* be true if the `multipart` attribute is
 `true`, or an exception will be thrown.


**Note:** Synchronous requests on the main thread can
 be easily disruptive to the user experience and should be avoided; in fact, many
 browsers have deprecated synchronous XHR support on the main thread entirely.
 Synchronous requests are permitted in `Worker`s.


`user` Optional

 The optional user name to use for authentication purposes; by default, this is the
 `null` value.


`password` Optional

 The optional password to use for authentication purposes; by default, this is the
 `null` value.


### Return value

None (`undefined`).

Specifications
--------------

| Specification |
| --- |
| XMLHttpRequest Standard # the-open()-method |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using XMLHttpRequest
* Related `XMLHttpRequest` methods:
 `setRequestHeader()`, `send()`, and
 `abort()`
XMLHttpRequest: mozAnon property
================================

**`XMLHttpRequest.mozAnon`** is a boolean. If true, the request will be sent without cookies or authentication headers.
XMLHttpRequest: statusText property
===================================

The read-only **`XMLHttpRequest.statusText`** property returns a string containing the response's status message as returned by the HTTP server. Unlike `XMLHTTPRequest.status` which indicates a numerical status code, this property contains the *text* of the response status, such as "OK" or "Not Found". If the request's `readyState` is in `UNSENT` or `OPENED` state, the value of `statusText` will be an empty string.

If the server response doesn't explicitly specify a status text, `statusText` will assume the default value "OK".

**Note:** Responses over an HTTP/2 connection will always have an empty string as status message as HTTP/2 does not support them.

Value
-----

A string.

Examples
--------


```js
const xhr = new XMLHttpRequest();
console.log("0 UNSENT", xhr.statusText);

xhr.open("GET", "/server", true);
console.log("1 OPENED", xhr.statusText);

xhr.onprogress = () => {
  console.log("3 LOADING", xhr.statusText);
};

xhr.onload = () => {
  console.log("4 DONE", xhr.statusText);
};

xhr.send(null);

/\*\*
 \* Outputs the following:
 \*
 \* 0 UNSENT
 \* 1 OPENED
 \* 3 LOADING OK
 \* 4 DONE OK
 \*/
```

Specifications
--------------

| Specification |
| --- |
| XMLHttpRequest Standard # the-statustext-attribute |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* List of HTTP status
* HTTP
* WHATWG Fetch Living Standard
XMLHttpRequest: overrideMimeType() method
=========================================

 The `XMLHttpRequest` method
 **`overrideMimeType()`** specifies a MIME type other than the
 one provided by the server to be used instead when interpreting the data being
 transferred in a request.

 This may be used, for example, to force a stream to
 be treated and parsed as `"text/xml"`, even if the server does not report it
 as such. This method must be called before calling `send()`.

Syntax
------


```js
overrideMimeType(mimeType)
```

### Parameters

`mimeType`

 A string specifying the MIME type to use instead of the one
 specified by the server. If the server doesn't specify a type,
 `XMLHttpRequest` assumes `"text/xml"`.


### Return value

None (`undefined`).

Examples
--------

 This example specifies a MIME type of `"text/plain"`, overriding the
 server's stated type for the data being received.


**Note:** If the server doesn't provide a
 `Content-Type`
 header, `XMLHttpRequest` assumes that the MIME type is
 `"text/xml"`. If the content isn't valid XML, an "XML Parsing Error: not
 well-formed" error occurs. You can avoid this by calling
 `overrideMimeType()` to specify a different type.



```js
// Interpret the received data as plain text

req = new XMLHttpRequest();
req.overrideMimeType("text/plain");
req.addEventListener("load", callback, false);
req.open("get", url);
req.send();
```

Specifications
--------------

| Specification |
| --- |
| XMLHttpRequest Standard # the-overridemimetype()-method |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using XMLHttpRequest
* `XMLHttpRequest.responseType`
XMLHttpRequest: channel property
================================

XMLHttpRequest.channel is an `nsIChannel` that used by the object when performing the request. This is `null` if the channel hasn't been created yet. In the case of a multi-part request, this is the initial channel, not the different parts in the multi-part request. **Requires elevated privileges to access.**
XMLHttpRequest: upload property
===============================

The `XMLHttpRequest` `upload` property returns an `XMLHttpRequestUpload` object that can be observed to monitor an upload's progress.

It is an opaque object, but because it's also an `XMLHttpRequestEventTarget`, event listeners can be attached to track its process.

**Note:** Attaching event listeners to this object prevents the request from being a "simple request" and will cause a preflight request to be issued if cross-origin; see CORS. Because of this, event listeners need to be registered before calling `send()` or upload events won't be dispatched.

**Note:** The spec also seems to indicate that event listeners should be attached after `open()`. However, browsers are buggy on this matter, and often need the listeners to be registered *before* `open()` to work.

The following events can be triggered on an upload object and used to monitor the upload:

| Event | Description |
| --- | --- |
| `loadstart` | The upload has begun. |
| `progress` | Periodically delivered to indicate the amount of progress made so far. |
| `abort` | The upload operation was aborted. |
| `error` | The upload failed due to an error. |
| `load` | The upload completed successfully. |
| `timeout` | 
 The upload timed out because a reply did not arrive within the time
 interval specified by the
 `XMLHttpRequest.timeout`.
  |
| `loadend` | 
 The upload finished. This event does not differentiate between success
 or failure, and is sent at the end of the upload regardless of the
 outcome. Prior to this event, one of `load`,
 `error`, `abort`, or `timeout` will
 already have been delivered to indicate why the upload ended.
  |

Specifications
--------------

| Specification |
| --- |
| XMLHttpRequest Standard # the-upload-attribute |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using XMLHttpRequest
* `XMLHttpRequestUpload`
XMLHttpRequest: readystatechange event
======================================

The `readystatechange` event is fired whenever the `readyState` property of the `XMLHttpRequest` changes.

**Warning:** This should not be used with synchronous requests and must
 not be used from native code.


Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("readystatechange", (event) => {});

onreadystatechange = (event) => {};
```

Event type
----------

A generic `Event` with no added properties.

Examples
--------


```js
const xhr = new XMLHttpRequest();
const method = "GET";
const url = "https://developer.mozilla.org/";

xhr.open(method, url, true);
xhr.onreadystatechange = () => {
  // In local files, status is 0 upon success in Mozilla Firefox
  if (xhr.readyState === XMLHttpRequest.DONE) {
    const status = xhr.status;
    if (status === 0 || (status >= 200 && status < 400)) {
      // The request has been completed successfully
      console.log(xhr.responseText);
    } else {
      // Oh no! There has been an error with the request!
    }
  }
};
xhr.send();
```

Specifications
--------------

| Specification |
| --- |
| XMLHttpRequest Standard # event-xhr-readystatechange |
| XMLHttpRequest Standard # handler-xhr-onreadystatechange |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
RTCCertificateStats: fingerprintAlgorithm property
==================================================

The **`fingerprintAlgorithm`** property of the `RTCCertificateStats` dictionary is a string containing the name of the hash function used to generate the `fingerprint` value in the associated `RTCCertificate`.

Value
-----

A string containing the name of the hash function used to create the fingerprint of the associated certificate.

Allowed values are: `"sha-1"`, `"sha-224"`, `"sha-256"`,`"sha-384"`, `"sha-512"`, `"md5"`, `"md2"`.

Specifications
--------------

| Specification |
| --- |
| Identifiers for WebRTC's Statistics API # dom-rtccertificatestats-fingerprintalgorithm |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
RTCCertificateStats: timestamp property
=======================================

The **`timestamp`** property of the `RTCCertificateStats` dictionary is a `DOMHighResTimeStamp` object specifying the time at which the data in the object was sampled.

Value
-----

A `DOMHighResTimeStamp` value indicating the time at which the activity described by the statistics in this object was recorded, in milliseconds elapsed since the beginning of January 1, 1970, UTC.

The value should be accurate to within a few milliseconds but may not be entirely precise, either because of hardware or operating system limitations or because of fingerprinting protection in the form of reduced clock precision or accuracy.

Specifications
--------------

| Specification |
| --- |
| Identifiers for WebRTC's Statistics API # dom-rtcstats-timestamp |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
RTCCertificateStats: fingerprint property
=========================================

The **`fingerprint`** property of the `RTCCertificateStats` dictionary is a string containing the fingerprint value of the associated `RTCCertificate`.

Value
-----

A string containing the fingerprint of the associated certificate.

 This is a lowercase hex string, calculated using the hash function specified in the `fingerprintAlgorithm` property.
 The format is more precisely defined in RFC4572, Section 5.

Specifications
--------------

| Specification |
| --- |
| Identifiers for WebRTC's Statistics API # dom-rtccertificatestats-fingerprint |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
RTCCertificateStats: id property
================================

The **`id`** property of the `RTCCertificateStats` dictionary is a string that uniquely identifies the object for which this object provides statistics.

Using the `id`, you can correlate this statistics object with others, in order to monitor statistics over time for a given WebRTC object, such as an `RTCPeerConnection`, or an `RTCDataChannel`.

Value
-----

A string that uniquely identifies the object for which this `RTCCertificateStats` object provides statistics.

The format of the ID string is not defined by the specification, so you cannot reliably make any assumptions about the contents of the string, or assume that the format of the string will remain unchanged for a given object type.

Specifications
--------------

| Specification |
| --- |
| Identifiers for WebRTC's Statistics API # dom-rtcstats-id |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
RTCCertificateStats: type property
==================================

The **`type`** property of the `RTCCertificateStats` dictionary is a string with the value `"certificate"`.

 Different statistics are obtained by iterating the `RTCStatsReport` object returned by a call to `RTCPeerConnection.getStats()`.
 The type indicates the set of statistics available through the object in a particular iteration step.
 A value of `"certificate"` indicates that the statistics available in the current step are those defined in `RTCCertificateStats`.

Value
-----

A string with the value `"certificate"`.

Specifications
--------------

| Specification |
| --- |
| Identifiers for WebRTC's Statistics API # dom-rtcstats-type |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
RTCCertificateStats: base64Certificate property
===============================================

The **`base64Certificate`** property of the `RTCCertificateStats` dictionary is a string containing the base-64 representation of the DER-encoded certificate.

This is essentially an encoding of the original certificate as a string that can safely serialized and deserialized when sent over an IP network.

Value
-----

A Base64 representation of the DER-encoded certificate.

Specifications
--------------

| Specification |
| --- |
| Identifiers for WebRTC's Statistics API # dom-rtccertificatestats-base64certificate |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
RTCCertificate: expires property
================================

The read-only **`expires`** property of the `RTCCertificate` interface returns the expiration date of the certificate.

 By default a new certificate is configured with `expires` set to a value of 2592000000 milliseconds, or 30 days.
 The expiration time cannot exceed 31536000000 milliseconds, or 365 days.
 It's also useful to note that browsers may further restrict the expiration time of certificates if they choose.

Value
-----

A timestamp, given as Unix time in milliseconds, containing the expiration date of the certificate.

Examples
--------


```js
RTCPeerConnection.generateCertificate({
  name: "RSASSA-PKCS1-v1\_5",
  hash: "SHA-256",
  modulusLength: 2048,
  publicExponent: new Uint8Array([1, 0, 1]),
}).then((cert) => {
  const pc = new RTCPeerConnection({ certificates: [cert] });
  console.log(cert.expires); // 2592000000 (30 days, the default)
});
```

Specifications
--------------

| Specification |
| --- |
| WebRTC: Real-Time Communication in Browsers # dom-rtccertificate-expires |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `RTCPeerConnection.generateCertificate()`
PositionSensorVRDevice: getState() method
=========================================

**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The **`getState()`** method of the `PositionSensorVRDevice` interface returns the current state of the position sensor for the current frame (e.g. within the current `window.requestAnimationFrame` callback) or for the previous frame, contained with a `VRPose` object. This is the method you'd normally want to use, vs. `PositionSensorVRDevice.getImmediateState`.

Syntax
------


```js
getState()
```

### Parameters

None.

### Return value

A `VRPose` object.

Examples
--------

The following example uses the WebVR API to update the view of a simple `2D canvas` scene on each frame of a `requestAnimationFrame` loop.


```js
function setView() {
  const posState = gPositionSensor.getState();
  if (posState.hasPosition) {
    posPara.textContent = `Position: x${roundToTwo(
 posState.position.x,
 )} y${roundToTwo(posState.position.y)} z${roundToTwo(posState.position.z)}`;
    xPos = -posState.position.x \* WIDTH \* 2;
    yPos = posState.position.y \* HEIGHT \* 2;
    zPos = -posState.position.z > 0.01 ? -posState.position.z : 0.01;
  }

  if (posState.hasOrientation) {
    orientPara.textContent = `Orientation: x${roundToTwo(
 posState.orientation.x,
 )} y${roundToTwo(posState.orientation.y)} z${roundToTwo(
 posState.orientation.z,
 )}`;
    xOrient = posState.orientation.x \* WIDTH;
    yOrient = -posState.orientation.y \* HEIGHT \* 2;
    zOrient = posState.orientation.z \* 180;
  }
}
```


Here we are grabbing a `VRPose` object using `getState()` and storing it in `posState`. We then check to make sure that position and orientation info is present in the current frame using `VRPose.position` and `VRPose.orientation` (these return `null` if, for example the head mounted display is turned off or not pointing at the position sensor, which would cause an error.)

We then output the x, y and z position and orientation values for informational purposes, and use those values to update the `xPos`, `yPos`, `zPos`, `xOrient`, `yOrient`, and `zOrient` variables, which are used to update the scene rendering on each frame.

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* WebVR API
PositionSensorVRDevice: resetSensor() method
============================================

**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The **`resetSensor()`** method of the `VRDisplay` interface *can be used to reset the sensor if desired, returning the* position and orientation values to zero.

Syntax
------


```js
resetSensor()
```

### Parameters

None.

### Return value

None (`undefined`).

Examples
--------

The following demo uses the WebVR API to update the view of a simple `2D canvas` scene on each frame of a `requestAnimationFrame` loop. It features, among other things, a "Reset Sensor" button in the UI, which when pressed runs the `resetSensor()` function on the position sensor. The JavaScript looks like this:


```js
document.querySelector("button").onclick = () => {
  gPositionSensor.resetSensor();
};
```


When the button is pressed, the current position, orientation, etc. of the sensor/head mounted display is set to be 0 — this makes the method useful for calibration when an app is first loaded.

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* WebVR API
WritableStreamDefaultWriter: desiredSize property
=================================================

 The **`desiredSize`** read-only property of the
 `WritableStreamDefaultWriter` interface returns the desired size required
 to fill the stream's internal queue.

Value
-----

An integer. Note that this can be negative if the queue is over-full.

 The value will be `null` if the stream cannot be successfully written to
 (due to either being errored, or having an abort queued up), and zero if the stream is
 closed.

### Exceptions

`TypeError`

The writer's lock is released.

Examples
--------


```js
const writableStream = new WritableStream(
  {
    write(chunk) {
      // ...
    },
    close() {
      // ...
    },
    abort(err) {
      // ...
    },
  },
  queuingStrategy,
);

// ...

const writer = writableStream.getWriter();

// ...

// return stream's desired size
let size = writer.desiredSize;
```

Specifications
--------------

| Specification |
| --- |
| Streams Standard # ref-for-default-writer-desired-size⑥ |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
WritableStreamDefaultWriter: releaseLock() method
=================================================

 The **`releaseLock()`** method of the
 `WritableStreamDefaultWriter` interface releases the writer's lock on the
 corresponding stream. After the lock is released, the writer is no longer active. If the
 associated stream is errored when the lock is released, the writer will appear errored
 in the same way from now on; otherwise, the writer will appear closed.

Syntax
------


```js
releaseLock()
```

### Parameters

None.

### Return value

None (`undefined`).

Examples
--------


```js
const writableStream = new WritableStream(
  {
    write(chunk) {
      // ...
    },
    close() {
      // ...
    },
    abort(err) {
      // ...
    },
  },
  queuingStrategy,
);

// ...

const writer = writableStream.getWriter();

// ...

// release writer's lock on the stream when desired
writer.releaseLock();
```

Specifications
--------------

| Specification |
| --- |
| Streams Standard # ref-for-default-writer-release-lock② |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.