API-Version: 1.9

net

Source:

Methods

<static> allCookies() → {Array[Cookie]}

Gets all cookies from the cookie jar.

Since:
  • 1.5
Source:
Returns:

An array of cookies

Type
Array[Cookie]

<static> clearCookies()

Clears all cookies from the internal cookie jar, i.e. all persistent and all session cookies.

Since:
  • 1.5
Source:

<static> domainFromHost(hostname) → {String}

Gets the base domain name from a hostname where the base domain name is the effective second level domain name, e.g. for www.example.com it will be example.com, for www.example.co.uk it will be example.co.uk.

Parameters:
Name Type Description
hostname String

A hostname

Source:
Returns:

The effective second level domain

Type
String

<static> domainMatch(domain, match) → {Boolean}

Checks if two domain matches checking for .tld which matches all top level domains

Parameters:
Name Type Description
domain String

The domain to test

match String

A domain that may contain .tld as top level domain

Source:
Returns:

Whether the domains match

Type
Boolean
Example
 
net.domainMatch("example.com", "example.tld"); // true
net.domainMatch("example.com", "example.org"); // false

<static> hostMatch(domain, match) → {Boolean}

Checks if hostnames match checking for .tld which matches all top level domains

Parameters:
Name Type Description
domain String

The host to test

match String

A host name that may contain .tld as top level domain

Source:
Returns:

Whether the hosts match

Type
Boolean
Example
 
net.hostMatch("www.example.com", "www.example.tld"); // true
net.hostMatch("www.example.com", "example.tld"); // false
net.hostMatch("www.example.com", "www.example.com"); // false

<static> parseUri(uri)SoupUri

Parses an uri to a SoupUri object

Parameters:
Name Type Description
uri String

The uri to parse

Source:
Returns:

A parsed uri or null if the uri isn't valid according to RFC 3986.

Type
@link SoupUri

<static> persistentCookies() → {Array[Cookie]}

Gets all persistent cookies from the cookie jar.

Since:
  • 1.5
Source:
Returns:

An array of cookies, if there are no persistent cookies it returns an empty array.

Type
Array[Cookie]

<static> sendRequest(uri, callback, method, data) → {Boolean}

Sends a http-request

Parameters:
Name Type Argument Description
uri String

The uri the request will be sent to.

callback net~onResponse

A callback that will be called when the request is finished

method String <optional>

The http request method, default GET

data Object <optional>

An object if method is POST

Properties
Name Type Description
contentType String

The content type

data String

The data that will be sent with the request

Source:
Returns:

true if the request was sent

Type
Boolean

<static> sendRequestSync(uri, method) → {Object}

Sends a http-request synchronously

Parameters:
Name Type Argument Description
uri String

The uri the request will be sent to.

method String <optional>

The http request method, default GET

Source:
Returns:

Object that contains the response body, the response headers and the http status code of the request.

Type
Object

<static> sessionCookies() → {Array[Cookie]}

Gets all session cookies from the cookie jar.

Since:
  • 1.5
Source:
Returns:

An array of cookies, if there are no session cookies it returns an empty array.

Type
Array[Cookie]

Type Definitions

onResponse(data, message)

Callback called when a response from a request was retrieved

Parameters:
Name Type Description
data Object
Properties
Name Type Description
body String

The message body

he Object

An object that contains all response headers

message SoupMessage

The soup message

Source: