http
- Description:
- The Device HTTP library.
Allows drivers to execute HTTP(s) requests towards the device.
Example
D.device.http
See HTTP Driver Examples
Methods
(static) delete(options, callback)
- Description:
- Executes an HTTP DELETE request towards the device.
Example
D.device.http.delete(options, callback)
Parameters:
Name |
Type |
Description |
options |
object
|
The HTTP request options
Properties
Name |
Type |
Attributes |
Default |
Description |
url |
string
|
|
|
The url suffix of the request target |
headers |
object
|
<optional>
|
|
The Request HTTP Headers defined as key value pairs. Eg {'Accept': 'text/html'} |
body |
string
|
<optional>
|
|
The Request HTTP Body |
port |
integer
|
<optional>
|
80
|
The port to use for the request. If protocol is set to https the default is 443 |
auth |
string
|
object
|
<optional>
|
|
The authentication to use. Eg 'basic' / {'bearer': 'the token'} |
username |
string
|
<optional>
|
|
The device username. If not set the custom driver management purpose one is used |
password |
string
|
<optional>
|
|
The device password. If not set the custom driver management purpose one is used |
jar |
boolean
|
<optional>
|
false
|
If true, remember cookies for future use |
useHostname |
boolean
|
<optional>
|
true
|
If false, ip address is used as host. If true or not set the device host_name is used as host |
protocol |
'http'
|
'https'
|
<optional>
|
'http'
|
The protocol to use in the request |
|
callback |
function
|
The HTTP request execution callback
Properties
Name |
Type |
Description |
error |
Error
|
null
|
The HTTP response error |
response |
Object
|
null
|
The HTTP response object
Properties
Name |
Type |
Description |
body |
string
|
null
|
The HTTP response body |
|
|
(static) get(options, callback)
- Description:
- Executes an HTTP GET request towards the device.
Example
D.device.http.get(options, callback)
Parameters:
Name |
Type |
Description |
options |
object
|
The HTTP request options
Properties
Name |
Type |
Attributes |
Default |
Description |
url |
string
|
|
|
The url suffix of the request target |
headers |
object
|
<optional>
|
|
The Request HTTP Headers defined as key value pairs. Eg {'Accept': 'text/html'} |
body |
string
|
<optional>
|
|
The Request HTTP Body |
port |
integer
|
<optional>
|
80
|
The port to use for the request. If protocol is set to https the default is 443 |
auth |
string
|
object
|
<optional>
|
|
The authentication to use. Eg 'basic' / {'bearer': 'the token'} |
username |
string
|
<optional>
|
|
The device username. If not set the custom driver management purpose one is used |
password |
string
|
<optional>
|
|
The device password. If not set the custom driver management purpose one is used |
jar |
boolean
|
<optional>
|
false
|
If true, remember cookies for future use |
useHostname |
boolean
|
<optional>
|
true
|
If false, ip address is used as host. If true or not set the device host_name is used as host |
protocol |
'http'
|
'https'
|
<optional>
|
'http'
|
The protocol to use in the request |
|
callback |
function
|
The HTTP request execution callback
Properties
Name |
Type |
Attributes |
Description |
error |
Error
|
<optional>
|
The HTTP response error |
response |
Object
|
<optional>
|
The HTTP response object
Properties
Name |
Type |
Attributes |
Description |
body |
string
|
<optional>
|
The HTTP response body |
|
|
(static) getTLSCertificate(options, callback)
- Description:
- Retrieves the TLS certificate of the server.
Examples
D.device.http.getTLSCertificate(options, callback)
// callback returns (error, TLSData) where TLSData has the following format
{"issuer": "Issuer name", "expiry": "Apr 12 23:59:59 2015 GMT", "valid": false, "certError": "CERT_HAS_EXPIRED"}
Parameters:
Name |
Type |
Description |
options |
object
|
The getTLSCertificate options
Properties
Name |
Type |
Attributes |
Default |
Description |
port |
integer
|
<optional>
|
443
|
The port to use for the request. Default is 443 |
|
callback |
function
|
The TLS info callback
Properties
Name |
Type |
Attributes |
Description |
error |
ErrorResult
|
<optional>
|
Will be present if the execution resulted in an error |
response |
Object
|
|
The HTTP response object
Properties
Name |
Type |
Description |
issuer |
string
|
The issuer of the TLS certificate |
expiry |
string
|
The expiry date of the TLS certificate |
valid |
Boolean
|
True if the certificate is valid, false otherwise |
certError |
string
|
An error code if the certificate is not valid, null otherwise |
|
|
(static) post(options, callback)
- Description:
- Executes an HTTP POST request towards the device.
Example
D.device.http.post(options, callback)
Parameters:
Name |
Type |
Description |
options |
object
|
The HTTP request options
Properties
Name |
Type |
Attributes |
Default |
Description |
url |
string
|
|
|
The url suffix of the request target |
headers |
object
|
<optional>
|
|
The Request HTTP Headers defined as key value pairs. Eg {'Accept': 'text/html'} |
body |
string
|
<optional>
|
|
The Request HTTP Body |
port |
integer
|
<optional>
|
80
|
The port to use for the request. If protocol is set to https the default is 443 |
auth |
string
|
object
|
<optional>
|
|
The authentication to use. Eg 'basic' / {'bearer': 'the token'} |
username |
string
|
<optional>
|
|
The device username. If not set the custom driver management purpose one is used |
password |
string
|
<optional>
|
|
The device password. If not set the custom driver management purpose one is used |
jar |
boolean
|
<optional>
|
false
|
If true, remember cookies for future use |
useHostname |
boolean
|
<optional>
|
true
|
If false, ip address is used as host. If true or not set the device host_name is used as host |
protocol |
'http'
|
'https'
|
<optional>
|
'http'
|
The protocol to use in the request |
|
callback |
function
|
The HTTP request execution callback
Properties
Name |
Type |
Description |
error |
Error
|
null
|
The HTTP response error |
response |
Object
|
null
|
The HTTP response object
Properties
Name |
Type |
Description |
body |
string
|
null
|
The HTTP response body |
|
|
(static) put(options, callback)
- Description:
- Executes an HTTP PUT request towards the device.
Example
D.device.http.put(options, callback)
Parameters:
Name |
Type |
Description |
options |
object
|
The HTTP request options
Properties
Name |
Type |
Attributes |
Default |
Description |
url |
string
|
|
|
The url suffix of the request target |
headers |
object
|
<optional>
|
|
The Request HTTP Headers defined as key value pairs. Eg {'Accept': 'text/html'} |
body |
string
|
<optional>
|
|
The Request HTTP Body |
port |
integer
|
<optional>
|
80
|
The port to use for the request. If protocol is set to https the default is 443 |
auth |
string
|
object
|
<optional>
|
|
The authentication to use. Eg 'basic' / {'bearer': 'the token'} |
username |
string
|
<optional>
|
|
The device username. If not set the custom driver management purpose one is used |
password |
string
|
<optional>
|
|
The device password. If not set the custom driver management purpose one is used |
jar |
boolean
|
<optional>
|
false
|
If true, remember cookies for future use |
useHostname |
boolean
|
<optional>
|
true
|
If false, ip address is used as host. If true or not set the device host_name is used as host |
protocol |
'http'
|
'https'
|
<optional>
|
'http'
|
The protocol to use in the request |
|
callback |
function
|
The HTTP request execution callback
Properties
Name |
Type |
Description |
error |
Error
|
null
|
The HTTP response error |
response |
Object
|
null
|
The HTTP response object
Properties
Name |
Type |
Description |
body |
string
|
null
|
The HTTP response body |
|
|