Setting the Response Content

From RAD Studio
Jump to: navigation, search

Go Up to Creating HTTP Response Messages

For some requests, the response to the request message is entirely contained in the header properties of the response. In most cases, however, action item assigns some content to the response message. This content may be static information stored in a file, or information that was dynamically produced by the action item or its content producer.

You can set the content of the response message by using either the Content property or the ContentStream property.

The Content property is a string. Delphi strings are not limited to text values, so the value of the Content property can be a string of HTML commands, graphics content such as a bit-stream, or any other MIME content type.

Use the ContentStream property if the content for the response message can be read from a stream. For example, if the response message should send the contents of a file, use a System.Classes.TFileStream object for the ContentStream property. As with the Content property, ContentStream can provide a string of HTML commands or other MIME content type. If you use the ContentStream property, do not free the stream yourself. The Web response object automatically frees it for you.

Note: If the value of the ContentStream property is not nil, the Content property is ignored.

See Also