Topic Path: Symbol Reference > Classes > TIdHTTPResponseInfo Class > TIdHTTPResponseInfo Methods > ServeFile Method
TIdHTTPResponseInfo.ServeFile Method
function ServeFile(
    AContext: TIdContext; 
    aFile: String
): cardinal; virtual;
Client session of the HTTP response.
File to be included in the HTTP response. 

Cardinal - Number of bytes in the file written in the HTTP response.

ServeFile is a virtual Cardinal function used to return the contents of the file specified in AFile in the HTTP response. 

AContent is the client session in the HTTP server handling the client request for the specified file. 

ServeFile allows the HTTP response to easily include the ContentType, ContentLength, and file content for the request file as part of the HTTP response written to the client connection. 

When ContentType contains an empty string (''), the MIMe type for the file is retrieved using the MIME table in the HTTPServer for the response. 

ContentLength is set to the length of the file using the FileSizeByName by function. 

ServeFile causes the HTTP headers to be written to the client connection for the HTTP session making the request, followed immediately by the content for the file specified in aFile.

Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.