What is the way to make this with Indy ?
TIdHTTP in Indy 10 has 2 overloaded Options() methods:
procedure Options(AURL: string; AResponseContent: TStream); overload;
function Options(AURL: string
{$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF}
): string; overload;
What TIdHTTP does not have is native properties for the Origin and Access-Control-Request-... headers. However, you can use the TIdHTTP.Request.CustomHeaders property for those, eg:
FIdHttp.Request.CustomHeaders.Values['Origin'] := 'http://www.asite.com';
FIdHttp.Request.CustomHeaders.Values['Access-Control-Request-Method'] := ' POST';
FIdHttp.Request.CustomHeaders.Values['Access-Control-Request-Headers'] := 'access-control-request-method';
FIdHttp.ProtocolVersion := pv1_1;
Response := FIdHttp.Options('http://www.asite.com/MyURL/DoCmd');
or
FIdHttp.Options('http://www.asite.com/MyURL/DoCmd', AResponseContent);
What will happen if the OPTIONS is not implemented by the server ?
The server will likely return an error code, which TIdHTTP will raise as an EIdHTTPProtocolException exception unless you enable the hoNoProtocolErrorException flag in the TIdHTTP.HTTPOptions property.