Internet Direct (Indy)
Home
PreviousUpNext
TIdMultiPartFormDataStream Class

Implements support for MIME-like multipart form responses.

Pascal
TIdMultiPartFormDataStream = class(TIdBaseStream);

TIdMultiPartFormDataStream is a TIdBaseStream descendant that implements support for encapsulation of MIME-like "multipart" types in the content of an HTTP message body, as described in the Internet Standards documents: 

RFC 1867 - Form-based File Upload in HTML  

RFC 2388 - Returning Values from Forms: multipart/form-data  

TIdMultiPartFormDataStream is oriented towards handling HTTP messages specifically defined to carry HTML FORM data suitable for processing via the POST request method. TIdMultiPartFormDataStream includes support for uniformly representing both field and file upload requests, and a MIME compatible representation for field and file upload responses. 

Multipart form content for the stream can include values for the HTML INPUT elements with the following type attributes: 

 

CHECKBOX 
HIDDEN 
IMAGE 
PASSWORD 
RADIO 
RESET 
SUBMIT 
TEXT 
FILE 

 

TIdMultiPartFormDataStream uses the MIME media type "multipart/form-data" to specify the content-type for values in the HTTP message sent from a client to a server. Please note that the content-type "multipart/mixed" may be used when multiple files are included the multipart response. 

TIdMultiPartFormDataStream adheres to the rules for multipart MIME data streams as outlined in the Internet Standards document: 

RFC 2046 - Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types  

In forms, data items have both a unique name and a value. Data items are represented in TIdMultiPartFormDataStream as a series of message parts with a content-disposition header value of "form-data", as described in the Internet Standards document: 

RFC 2183 - Communicating Presentation Information in Internet Messages: The Content-Disposition Header Field  

The content-disposition header contains an (additional) parameter of "name", where the value of that parameter is the original field name in the form. For example, a part might contain a header: 

 

  Content-Disposition: form-data; name="user"

 

Form field names originally in non-ASCII character sets may be encoded within the value of the "name" parameter using the standard method, as described in the Internet Standards document: 

RFC 2047 - MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text  

As with all multipart MIME types, each part in the data stream has an optional "Content-Type" header, which defaults to the value "text/plain". If the contents of a file are returned using the form, then the file input is identified as the appropriate media type, if known, or the value "application/octet-stream". If multiple files are to be returned as the result of a single form entry, they should be represented as a "multipart/mixed" part embedded within the "multipart/form-data". 

Each part in the data stream may be encoded and the "content-transfer-encoding" header supplied when the value of that part does not conform to the default encoding. 

Use the AddFormField, AddFile, and AddObject methods to create data items and the corresponding values for the form data stream. 

TIdMultiPartFormDataStream is used in the overloaded TIdHTTP.Post method when sending a "multipart/form-data" request to an HTTP server.

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.