Internet Direct (Indy)
Home
PreviousUpNext
TIdCustomHTTP.Post Method (string, TIdStrings)

Send HTTP data to a web server or CGI program.

Pascal
function Post(
    AURL: string; 
    ASource: TIdStrings
): string; overload;
Parameters 
Description 
ASource 
String list or stream containing the request data. 
URL 
Location of the host or CGI application.
 

String - Values received in a Response for the HTTP POST method.

Post is an overloaded method that is used to send data specified in ASource to the resource location in AURL. Post is overloaded to allow use of either TIdStrings or TIdStream object instances in ASource, and also provides procedure- and function-based variants of the method to allow String return values or storage of return values in AResponseContent. 

By default, Indy will restrict all POST requests to the use of HTTP version 1.0 in the headers for the request. This occurs because some HTTP servers do not respect the RFC for HTTP 1.1 to the full extent of the specification. In particular, most servers do not send or expect to receive the 100-Continue HTTP header. 

To use HTTP version 1.1 requests when calling the Post method, include the value hoKeepOrigProtocol in the HTTPOptions property. Please note that this does not include retaining a HTTP persistent connection for the session; persistent connections established using the HTTP 'Keep-Alive' header are always closed prior to performing an HTTP Post operation. 

This variant of the Post method prepares an HTTP request from the values in ASource, and ensures that the content conforms to the default encoding used for HTML forms. This includes setting the content type in the Request to the value 'application/x-www-form-urlencoded' when it has been omitted or contains the value 'text/html'. Form field names and values in ASource should appear in the order used in the original HTML document with the field name separated from the field value by the '=' character. 

Field values in ASource will be encoded when the HTTPOptions property contains the value hoForceEncodeParams. Space characters (Decimal 32) are replaced with the character '+'. Other Reserved characters are scaped using the same notation that applies to URLs; that is, non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks in multi-line text field values are represented as CRLF pairs, i.e. `%0D%0A'. Field value encoding is performed by calling the TIdURI.ParamsEncode method for each line in ASource in NAME=VALUE format. 

Form field name and value pairs should be separated from each other using the '&' character. Any remaining CRLF line-end sequences found in ASource are replaced with the '&' character. 

Post calls an overloaded variant of the method to perform the HTTP transfer.

Exceptions 
Description 
EAssertionFailed 
Raised if the source string list for the request is unassigned. 
Internet Direct (Indy) version 10.1.5
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Website http://www.indyproject.org.
Post feedback to the Indy Documentation newsgroup.