![]() |
![]() ![]() ![]() |
WinHTTP component.
|
type
|
TWinHTTPRequestMethod = (rmAutoDetect, rmGET, rmPOST);
|
|
property RequestMethod: TWinHTTPRequestMethod;
|
The RequestMethod (HTTP method) property is instruction sent in a request message that notifies an HTTP server of the action to perform on the specified resource.
|
|
For example, rmGET specifies that a resource is being retrieved from the server. rmPOST specifies that client should upload (post) some specific information which should processed by server before downloading the data.
|
|
When RequestMethod is rmAutoDetect, the HTTP component will autimatically detect how to request data from server. When POSTData string is empty, component will use GET method. If POSTData specified, POST method will be used.
|
|
![]() |
|
If CGI program accepts data via POST method, you should specify required data in the POSTData property together with the URL string.
|
|
procedure TForm1.ReadBtnClick(Sender: TObject);
|
begin
|
WinHTTP1.URL := 'http://www.delphipages.com/result.cfm?SR=HTTP&AO=and&RequestTimeout=500';
|
WinHTTP1.Read;
|
end;
|
|
procedure TForm1.WinHTTP1Done(Sender: TObject; ContentType: string; FileSize: Integer; Stream: TStream);
|
begin
|
// Receiving content from Stream
|
end;
|
|
{ Click link below to see demo:
|
http://www.delphipages.com/result.cfm?SR=HTTP&AO=and&RequestTimeout=500 }
|
procedure TForm1.ReadBtnClick(Sender: TObject);
|
begin
|
WinHTTP1.URL := 'http://www.torry.net/quicksearch.php';
|
WinHTTP1.POSTData := 'String=HTTP&Exact=Yes&Title=No';
|
WinHTTP1.Read;
|
end;
|
|
procedure TForm1.WinHTTP1Done(Sender: TObject; ContentType: string; FileSize: Integer; Stream: TStream);
|
begin
|
// Receiving content from Stream
|
end;
|
URL property.
|