TsgcWebSocketServer_HTTPAPI | Send File Response

Use the FileName property of THttpServerResponse object if you want to send a filename as a response to a HTTP request.

 


procedure OnHTTPRequest(aConnection: TsgcWSConnection_HTTPAPI; 
	const aRequestInfo: THttpServerRequest; 
	var aResponseInfo: THttpServerResponse);
begin
  if aRequestInfo.Method = 'GET' then
  begin
    if aRequestInfo.Document = '/test.zip' then
	begin
	  aResponseInfo.ResponseNo := 200;
	  aResponseInfo.FileName := 'c:\download\test.zip';
	  aResponseInfo.ContentType := 'application/zip';
	end
	else
	  aResponseInfo.ResponseNo := 404;
  end
  else 
    aResponseInfo.ResponseNo := 500;
end;