TsgcWebSocketServer_HTTPAPI | Custom Headers

You can customize the response of HTTP.SYS server using the CustomHeaders property of response object.

 

Set the value of CustomHeaders with the Header Name and Header Value separated by newline characters.

 

Example: if you want to add the following headers, find below a sample code

 

Access-Control-Allow-Origin: *

Acces-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE

 


procedure OnHTTPRequest(aConnection: TsgcWSConnection_HTTPAPI; const aRequestInfo: THttpServerRequest; 
  var aResponseInfo: THttpServerResponse);
begin
  aResponseInfo.ResponseNo := 200;
  aResponseInfo.CustomHeaders := 'Access-Control-Allow-Origin: *' + #13#10 + 'Acces-Control-Allow-Methods: ' +
    'GET, POST, OPTIONS, PUT, PATCH, DELETE';
end;