Network
Last updated
Was this helpful?
Last updated
Was this helpful?
The functions for network/internet operations are described here.
The hinfo type is used to get url address information and has the following fields:
int Status - response status.
int Length - content size. It may not be specified (equal to 0).
str Type - content type. For example, text/html; charset=UTF-8.
The Download function downloads the file from the specified URL and saves it with the specified filename. The function returns the size of the downloaded file.
The HeadInfo function sends a HEAD request to the specified url and returns the hinfo structure.
The HTTPGet function sends a GET request to the specified URL and returns a response as a buf variable. The function can be used to download small files without saving them to disk.
The HTTPPage function sends a GET request to the specified URL and returns a string response.
The HTTPRequest function sends an HTTP request to the specified URL and returns the response as a string. In the method parameter you need to specify the calling method - GET, POST, UPDATE, PUT, DELETE. The function also allows you to specify parameters and request headers. They are described as associative arrays where parameter name or header name is specified as a key. By default, the parameters are passed as form data when POST is called. If you want to send them in JSON format, then specify "Content-Type": "application/json; charset=UTF-8" in the headers parameter.