System.Net.HttpClient.THTTPClient.InternalExecuteAsync

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function InternalExecuteAsync(const AsyncCallback: TAsyncCallback; const AsyncCallbackEvent: TAsyncCallbackEvent;  const ARequest: IHTTPRequest; const AContentStream: TStream; const AHeaders: TNetHeaders; AOwnsSourceStream: Boolean): IAsyncResult;

C++

System::Types::_di_IAsyncResult __fastcall InternalExecuteAsync(const System::Classes::_di_TAsyncCallback AsyncCallback, const System::Classes::TAsyncProcedureEvent AsyncCallbackEvent, const _di_IHTTPRequest ARequest, System::Classes::TStream* const AContentStream, const System::DynamicArray<System::Net::Urlclient::TNameValuePair> AHeaders, bool AOwnsSourceStream);

Properties

Type Visibility Source Unit Parent
function protected
System.Net.HttpClient.pas
System.Net.HTTPClient.hpp
System.Net.HttpClient THTTPClient

Description

Starts an asynchronous HTTP request.

When you call InternalExecuteAsync, you must provide the data required to perform your HTTP request:

  • AsyncCallback is a callback procedure to be called when a response is received or the request fails.
  • AsyncCallbackEvent is an event handler to be called when a response is received or the request fails if AsyncCallback is nil.
  • ARequest is the HTTP request method to send.
  • AContentStream is a stream to hold the data included in the response.
  • AHeaders is a list of headers to include in the request.
  • AOwnsSourceStream determines whether ASourceStream should be freed when the request is submitted (True) or not (False).

InternalExecuteAsync returns an asynchronous result object that starts being filled with the response data asynchronously.

When all the response data is received into the response object, the callback function or event handler is called, and provides the corresponding response object as a parameter.

Call EndAsyncHTTP with the target asynchronous result object as a parameter to ensure that the operation succeeded; EndAsyncHTTP raises an exception if there was any issue during the request, such as a timeout.

You usually call EndAsyncHTTP inside the callback function or event handler, where you know that the response data has been received already. However, you can actually call EndAsyncHTTP at any moment, which stops the program execution until the response data is received, effectively turning the asynchronous request into a synchronous request.

BeginExecute and DoExecuteAsync call InternalExecuteAsync.

See Also