Merge branch 'main' into new-animation-features

This commit is contained in:
MihailRis 2026-09-15 21:04:28 +03:00
commit 9f40303661
17 changed files with 468 additions and 340 deletions

View file

@ -4,6 +4,39 @@ A library for working with the network.
## HTTP requests
There is a configurable function `network.request` that allows performing HTTP requests with various methods (GET, POST, PUT, DELETE, etc.) and configuring headers, request body, timeout, and other parameters.
> To pass binary data in the request body, use a byte array (Bytearray) or a string. In `on_response`, the `body` string can be converted to a byte array using `Bytearray(response.body)`.
```lua
network.request(
url: string,
parameters: {
-- Request method (GET, POST, PUT, DELETE, etc.)
method: string,
-- Request body as a string or Bytearray
body: table|string,
-- List of additional request headers
headers: table<string>,
-- Timeout in milliseconds
timeout: int,
-- Whether to verify the SSL certificate
verify_ssl: boolean,
-- Function called when a response is received
on_response: function(response: {
-- HTTP response status code
status: int,
-- Response body as a string
body: string,
-- List of response headers
headers: table<string>
}),
}
)
```
### Simplified functions for GET and POST requests
```lua
-- Performs a GET request to the specified URL.
network.get(

View file

@ -4,6 +4,39 @@
## HTTP-Запросы
Существует настраиваемая функция `network.request`, которая позволяет выполнять HTTP-запросы с различными методами (GET, POST, PUT, DELETE и т.д.) и настраивать заголовки, тело запроса, таймаут и другие параметры.
> Для передачи двоичных данных в теле запроса, используйте массив байт (Bytearray) или строку. В `on_response` строку `body` можно преобразовать в массив байт с помощью `Bytearray(response.body)`.
```lua
network.request(
url: string,
parameters: {
-- Метод запроса (GET, POST, PUT, DELETE и т.д.)
method: string,
-- Тело запроса в виде строки или массива байт (Bytearray)
body: table|string,
-- Список дополнительных заголовков запроса
headers: table<string>,
-- Таймаут в миллисекундах
timeout: int,
-- Проверять ли SSL-сертификат
verify_ssl: boolean,
-- Функция, вызываемая при получении ответа
on_response: function(response: {
-- HTTP-код ответа
status: int,
-- Тело ответа в виде строки
body: string,
-- Список заголовков ответа
headers: table<string>
}),
}
)
```
### Упрощённые функции для GET и POST запросов
```lua
-- Выполняет GET запрос к указанному URL.
network.get(
@ -231,4 +264,4 @@ network.get_total_download() -> int
```lua
-- Ищет свободный для использования порт.
network.find_free_port() -> int | nil
```
```