Net

View as Markdown

Functions

httpRequest

Performs a regular HTTP or HTTPS request. To perform an HTTPS request, insert “https://” at the URL’s beginning. The default request method is GET, TCP connect timeout is 6 seconds and total request timeout is 90 seconds. Learn more about the limits(/docs/guides/voxengine/limits).

1httpRequest(url: string, callback: (result: HttpRequestResult) => void, options?: HttpRequestOptions): void

Parameters

url
stringRequired
callback
(result: HttpRequestResult) => voidRequired
options
HttpRequestOptions

httpRequestAsync

Performs an asynchronous HTTP request. TCP connect timeout is 6 seconds and total request timeout is 90 seconds. Learn more about the limits(/docs/guides/voxengine/limits).

1httpRequestAsync(url: string, options?: HttpRequestOptions): Promise<HttpRequestResult>

Parameters

url
stringRequired
options
HttpRequestOptions

sendMail

Send email via the specified email server

1sendMail(mailServerAddress: string, from: string, to: string | string[], title: string, body: string, callback: (result: SendMailResult) => void, options?: SendMailOptions): void

Parameters

mailServerAddress
stringRequired
from
stringRequired
to
string | string[]Required
title
stringRequired
body
stringRequired
callback
(result: SendMailResult) => voidRequired
options
SendMailOptions

sendMailAsync

Send an email via a specified email server

1sendMailAsync(mailServerAddress: string, from: string, to: string | string[], title: string, body: string, options?: SendMailOptions): Promise<SendMailResult>

Parameters

mailServerAddress
stringRequired
from
stringRequired
to
string | string[]Required
title
stringRequired
body
stringRequired
options
SendMailOptions

Types

HttpRequestOptions

Advanced HTTP request options.

connectionTimeout
number

optional

Optional. Timeout for the TCP connection to the address in seconds. The default value is 6. The value can be only decreased.

enableSystemLog
boolean

optional

Optional. Whether to enable logging the POST request body. The default value is false.

headers
{ [key: string]: string }

optional

Optional. Request headers: {‘Content-Type’: ‘text/html; charset=utf-8’, ‘User-Agent’: ‘YourCustomUserAgent/1.0’}. Note that the default value for the ‘User-Agent’ header is VoxEngine/1.0.

method
string

optional

HTTP request type as a string: GET, POST etc. The default value is GET.

params
{\n [key: string]: string;\n }

optional

Optional. Request parameters. They can be specified in the URL itself as well.

postData
string | number[]

optional

Optional. Raw UTF-8 encoded data string or an array of bytes in any encoding generated by str2bytes(/docs/references/voxengine/str2bytes) to send as the HTTP request body when ‘method’ is set to POST, PUT, or PATCH.

rawOutput
boolean

optional

Optional. Whether HttpRequestResult.data(/docs/references/voxengine/net/httprequestresult#data) should contain a list of 1-byte numbers corresponding to the HTTP response data. If set to false, HttpRequestResult.data(/docs/references/voxengine/net/httprequestresult#data) is undefined.

timeout
number

optional

Optional. Timeout for getting a response to the request in seconds. The default value is 90. The value can be only decreased.

HttpRequestResult

HTTP response.

code
number

Response code. HTTP code (2xx-5xx) or one of our internal status codes 0Voxengine limits are violated (e.g. HTTP request count exceeded)-1Unknown error-2Malformed URL-3Host not found-4Connection error-5Too many redirects-6Network error-7Timeout-8Internal error-9Server response is larger than 2 MB

data
number[]

optional

If HttpRequestOptions.rawOutput(/docs/references/voxengine/net/httprequestoptions#rawoutput) is true, data contains a list of 1-byte numbers corresponding to HTTP response data. If HttpRequestOptions.rawOutput(/docs/references/voxengine/net/httprequestoptions#rawoutput) is false, data is undefined.

error
string

optional

In case of an error contains the error description

headers
{ key: string; value: string }[]

optional

List of dictionaries with key and value fields representing HTTP headers returned by the remote server

raw_headers
string

optional

HTTP header string returned by the remote server, without processing

text
string

optional

HTTP response body if Content-Type is not binary

SendMailOptions

Advanced options for sendMail method

bcc
string[]

optional

BCC addresses

cc
string[]

optional

CC addresses

html
string

optional

Alternative HTML body

login
string

Login for mail server

password
string

Password for mail server

port
number

Mail server port

SendMailResult

Result of sending an email

code
number

SMTP server response code

error
string

optional

Optional. SMTP server error message