Home API Manuals About Forum
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

HTTP_Get

Performs an HTTP GET request to the specified URL.

URL — the URL to request.

After the request completes, use HTTP_Header to get the response body and HTTP_Body to get the response headers. See the notes on HTTP_Body and HTTP_Header regarding the historical name swap.

In DWS, an optional second parameter LStream (TMemoryStream) can be provided. When set, the raw response body is written into this stream instead of being stored in the internal string buffer. This is useful for downloading binary data (e.g., images or files).

If the hostname cannot be resolved, the method logs an error to the system journal and returns without performing the request.

Выполняет HTTP GET-запрос по указанному URL.

URL — адрес запроса.

После выполнения запроса используйте HTTP_Header для получения тела ответа и HTTP_Body для получения заголовков. См. примечания к HTTP_Body и HTTP_Header об исторической путанице имён.

В DWS доступен необязательный второй параметр LStream (TMemoryStream). Если задан, сырое тело ответа записывается в этот поток вместо внутреннего строкового буфера. Полезно для скачивания бинарных данных (изображений, файлов).

Если имя хоста не удаётся разрешить, метод записывает ошибку в системный журнал и завершается без выполнения запроса.

Pascal

procedure HTTP_Get(URL: String; LStream: TMemoryStream = nil);

Python

def HTTP_Get(URL: str) -> None: ...

Pascal Example

begin
  HTTP_Get('https://httpbin.org/get');
  AddToSystemJournal('Body: ' + HTTP_Header);
end.

Download to stream (DWS):

var
  MS: TMemoryStream;
begin
  MS := TMemoryStream.Create;
  HTTP_Get('https://example.com/image.png', MS);
  AddToSystemJournal('Downloaded bytes: ' + IntToStr(MS.Size));
  MS.Free;
end.

Python Example

HTTP_Get('https://httpbin.org/get')
AddToSystemJournal(f'Body: {HTTP_Header()}')

See Also

HTTP_Post, HTTP_Body, HTTP_Header