Class: PaywallHttpRequest

PaywallHttpRequest()

new PaywallHttpRequest()

PaywallHttpRequest is the main class in this library. It's an paywall enhanced XMLHttpRequest what wraps a standard XMLHttpRequest and checks if response is 402 (Payment Required). If that is the case a web socket is automatically open to listen for settlement and later use that settlement token to automatically perform the call again with the same parameters.
Source:

Namespaces

paywall
upload

Methods

(static) abort()

Method to abort the call and close all underlying resources such as event bus and web socket.
Source:

(static) addEventListener(type, callback, options)

Method to add download event listener. The listener is cached until passing paywall. See standard EventTarget documentation for details.
Parameters:
Name Type Description
type type of event.
callback the call back function.
options callback options, see EventTarget documentation.
Source:

(static) dispatchEvent()

Method that shouldn't be called will throw error.
Source:

(static) getAllResponseHeaders() → {string}

Method to fetch all response headers from underlying XMLHttpRequest object.
Source:
Returns:
all response headers value.
Type
string

(static) getResponseHeader(name) → {string}

Method to fetch response header for underlying XMLHttpRequest object.
Parameters:
Name Type Description
name of resonse header.
Source:
Returns:
response header value.
Type
string

(static) open(method, url, async, username, password)

Method to open a connection to given URL and initializes underlying resources for paywall handling.
Parameters:
Name Type Description
method http method to use
url url to connecto to
async if call should be asynchronical (default true), optional.
username username to use with the call, optional
password password to use with the call, optional
Source:

(static) overrideMimeType(mime)

Method to override the default mime type sent in response.
Parameters:
Name Type Description
mime mine-type to override with.
Source:

(static) removeEventListener(type, callback, options)

Method to remove download event listener. The listener is cached until passing paywall. See standard EventTarget documentation for details.
Parameters:
Name Type Description
type type of event.
callback the call back function.
options callback options, see EventTarget documentation.
Source:

(static) send(body)

Method to send the request, data is cached to be sent again automatically after payment is settled.
Parameters:
Name Type Description
body optional body data to upload.
Source:

(static) setRequestHeader(name, value)

Method to set the related request header in underlying XMLHttpRequest object. The value is cached so subsequent call after passing paywall it is set again automatically.
Parameters:
Name Type Description
name request header name.
value request header value.
Source: