System.Net.URLClient.TURLClient.DoExecuteAsync

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function DoExecuteAsync(const AsyncCallback: TAsyncCallback; const AsyncCallbackEvent: TAsyncCallbackEvent; const ARequestMethod: string; const AURI: TURI;  const ASourceStream, AContentStream: TStream; const AHeaders: TNetHeaders; AOwnsSourceStream: Boolean = False): IAsyncResult; virtual;

C++

virtual System::Types::_di_IAsyncResult __fastcall DoExecuteAsync(const System::Classes::_di_TAsyncCallback AsyncCallback, const System::Classes::TAsyncProcedureEvent AsyncCallbackEvent, const System::UnicodeString ARequestMethod, const TURI &AURI, System::Classes::TStream* const ASourceStream, System::Classes::TStream* const AContentStream, const System::DynamicArray<TNameValuePair> AHeaders, bool AOwnsSourceStream = false);

Properties

Type Visibility Source Unit Parent
function protected
System.Net.URLClient.pas
System.Net.URLClient.hpp
System.Net.URLClient TURLClient

Description

Note: Subclasses of TURLClient must provide their own implementation of DoExecuteAsync, which should work as described below. When you call TURLClient.DoExecuteAsync, it raises an ENetURIClientException exception.

Starts an asynchronous URL request.

When you call DoExecuteAsync, you must provide the data required to perform your URL 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.
  • ARequestMethod is a string that defines the request method to use. Possible request methods depend on the protocol.
  • AURI is a URI that identifies the location of the resource that you request.
  • ASourceStream is a stream of data to provide in the request.
  • 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).

DoExecuteAsync 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 EndAsyncURL with the target asynchronous result object as a parameter to ensure that the operation succeeded; EndAsyncURL raises an exception if there was any issue during the request, such as a timeout.

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

BeginExecute calls DoExecuteAsync.

See Also