Topic Path: Symbol Reference > Classes > TIdHTTPResponseInfo Class > TIdHTTPResponseInfo Methods > SmartServeFile Method
TIdHTTPResponseInfo.SmartServeFile Method
function SmartServeFile(
    AContext: TIdContext; 
    ARequestInfo: TIdHTTPRequestInfo; 
    aFile: String
): cardinal;
Client session for the HTTP response.
Headers from the HTTP request.
File name form the HTTP request. 

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

SmartServeFile is a 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. 

SmartServeFile allows the HTTP response to easily include the headers and contents for the requested file if the file date in the "If-Modified-Since" header is within 2 seconds of the actual file timestamp. 

If the file in aFile has not been modified since the date and time requested in the HTTP "If-Modified-Since" header, the HTTP response code 304 is returned for the request. The return value for the method is 0 in this situation. 

SmartServeFile includes the ContentType and ContentLength headers in the request, and the contents for the file specified in aFile. 

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. 

SmartServeFile 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.