System.Net.HttpClient.THTTPClient.BeginExecute

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function BeginExecute(const ARequest: IHTTPRequest; const AContentStream: TStream = nil;  const AHeaders: TNetHeaders = nil): IHTTPResponse; overload;
function BeginExecute(const AsyncCallback: TAsyncCallback; const ARequest: IHTTPRequest;  const AContentStream: TStream = nil; const AHeaders: TNetHeaders = nil): IHTTPResponse; overload;
function BeginExecute(const AsyncCallbackEvent: TAsyncCallbackEvent; const ARequest: IHTTPRequest;  const AContentStream: TStream = nil; const AHeaders: TNetHeaders = nil): IHTTPResponse; overload;

C++

HIDESBASE _di_IHTTPResponse __fastcall BeginExecute(const _di_IHTTPRequest ARequest, System::Classes::TStream* const AContentStream = (System::Classes::TStream*)(0x0), const System::DynamicArray<System::Net::Urlclient::TNameValuePair> AHeaders = System::DynamicArray<System::Net::Urlclient::TNameValuePair>())/* overload */;
HIDESBASE _di_IHTTPResponse __fastcall BeginExecute(const System::Classes::_di_TAsyncCallback AsyncCallback, const _di_IHTTPRequest ARequest, System::Classes::TStream* const AContentStream = (System::Classes::TStream*)(0x0), const System::DynamicArray<System::Net::Urlclient::TNameValuePair> AHeaders = System::DynamicArray<System::Net::Urlclient::TNameValuePair>())/* overload */;
HIDESBASE _di_IHTTPResponse __fastcall BeginExecute(const System::Classes::TAsyncProcedureEvent AsyncCallbackEvent, const _di_IHTTPRequest ARequest, System::Classes::TStream* const AContentStream = (System::Classes::TStream*)(0x0), const System::DynamicArray<System::Net::Urlclient::TNameValuePair> AHeaders = System::DynamicArray<System::Net::Urlclient::TNameValuePair>())/* overload */;
inline System::Net::Urlclient::_di_IURLResponse __fastcall  BeginExecute(const System::UnicodeString ARequestMethod, const System::Net::Urlclient::TURI &AURI, System::Classes::TStream* const ASourceStream = (System::Classes::TStream*)(0x0), System::Classes::TStream* const AContentStream = (System::Classes::TStream*)(0x0), const System::DynamicArray<System::Net::Urlclient::TNameValuePair> AHeaders = System::DynamicArray<System::Net::Urlclient::TNameValuePair>()){ return System::Net::Urlclient::TURLClient::BeginExecute(ARequestMethod, AURI, ASourceStream, AContentStream, AHeaders); }
inline System::Net::Urlclient::_di_IURLResponse __fastcall  BeginExecute(const System::Classes::TAsyncProcedureEvent AsyncCallbackEvent, const System::UnicodeString ARequestMethod, const System::Net::Urlclient::TURI &AURI, System::Classes::TStream* const ASourceStream = (System::Classes::TStream*)(0x0), System::Classes::TStream* const AContentStream = (System::Classes::TStream*)(0x0), const System::DynamicArray<System::Net::Urlclient::TNameValuePair> AHeaders = System::DynamicArray<System::Net::Urlclient::TNameValuePair>()){ return System::Net::Urlclient::TURLClient::BeginExecute(AsyncCallbackEvent, ARequestMethod, AURI, ASourceStream, AContentStream, AHeaders); }
inline System::Net::Urlclient::_di_IURLResponse __fastcall  BeginExecute(const System::Classes::_di_TAsyncCallback AsyncCallback, const System::UnicodeString ARequestMethod, const System::Net::Urlclient::TURI &AURI, System::Classes::TStream* const ASourceStream = (System::Classes::TStream*)(0x0), System::Classes::TStream* const AContentStream = (System::Classes::TStream*)(0x0), const System::DynamicArray<System::Net::Urlclient::TNameValuePair> AHeaders = System::DynamicArray<System::Net::Urlclient::TNameValuePair>()){ return System::Net::Urlclient::TURLClient::BeginExecute(AsyncCallback, ARequestMethod, AURI, ASourceStream, AContentStream, AHeaders); }
inline System::Net::Urlclient::_di_IURLResponse __fastcall  BeginExecute(const System::UnicodeString ARequestMethod, const System::UnicodeString AURIStr, System::Classes::TStream* const ASourceStream = (System::Classes::TStream*)(0x0), System::Classes::TStream* const AContentStream = (System::Classes::TStream*)(0x0), const System::DynamicArray<System::Net::Urlclient::TNameValuePair> AHeaders = System::DynamicArray<System::Net::Urlclient::TNameValuePair>()){ return System::Net::Urlclient::TURLClient::BeginExecute(ARequestMethod, AURIStr, ASourceStream, AContentStream, AHeaders); }
inline System::Net::Urlclient::_di_IURLResponse __fastcall  BeginExecute(const System::Classes::TAsyncProcedureEvent AsyncCallbackEvent, const System::UnicodeString ARequestMethod, const System::UnicodeString AURIStr, System::Classes::TStream* const ASourceStream = (System::Classes::TStream*)(0x0), System::Classes::TStream* const AContentStream = (System::Classes::TStream*)(0x0), const System::DynamicArray<System::Net::Urlclient::TNameValuePair> AHeaders = System::DynamicArray<System::Net::Urlclient::TNameValuePair>()){ return System::Net::Urlclient::TURLClient::BeginExecute(AsyncCallbackEvent, ARequestMethod, AURIStr, ASourceStream, AContentStream, AHeaders); }
inline System::Net::Urlclient::_di_IURLResponse __fastcall  BeginExecute(const System::Classes::_di_TAsyncCallback AsyncCallback, const System::UnicodeString ARequestMethod, const System::UnicodeString AURIStr, System::Classes::TStream* const ASourceStream = (System::Classes::TStream*)(0x0), System::Classes::TStream* const AContentStream = (System::Classes::TStream*)(0x0), const System::DynamicArray<System::Net::Urlclient::TNameValuePair> AHeaders = System::DynamicArray<System::Net::Urlclient::TNameValuePair>()){ return System::Net::Urlclient::TURLClient::BeginExecute(AsyncCallback, ARequestMethod, AURIStr, ASourceStream, AContentStream, AHeaders); }

Properties

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

Description

Starts an asynchronous HTTP request.

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

  • ARequest is the HTTP request to execute.
  • AContentStream (optional) is a stream to hold the data included in the response.
  • AHeaders (optional) is a list of headers to include in the request.
  • AsyncCallback (optional) is a callback procedure to be called when a response is received or the request fails.
  • AsyncCallbackEvent (optional) is an event handler to be called when a response is received or the request fails.

BeginExecute returns a response object that starts being filled with the response data asynchronously. You can handle the OnReceiveData event to track the progress of the download of the response data.

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 response 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.

See Also