TsgcWebSocketHTTPServer › Olaylar › OnCommandOther
HTTP sunucusu GET, POST veya HEAD dışında bir yöntem aldığında tetiklenir (PUT, DELETE, OPTIONS, PATCH...).
property OnCommandOther: TIdHTTPCommandEvent;
// TIdHTTPCommandEvent = procedure(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo) of object
—
OnCommandOther, GET, POST veya HEAD olmayan HTTP yöntemleri (PUT, DELETE, OPTIONS, PATCH, TRACE...) için tetiklenir. Hangi fiilin kullanıldığını öğrenmek için ARequestInfo.Command'ı ve hedef URI için ARequestInfo.Document'ı inceleyin; OnCommandGet'te olduğu gibi AResponseInfo.ContentText/ContentStream, ContentType ve ResponseNo'yu doldurun. Bu olayı işlemek, GET/POST'un ötesindeki fiilleri kabul eden REST endpoint'leri uygulamanın olağan yoludur; istek ayrıca yetkilendirme denetimi gerektirdiğinde OnBeforeCommand ile birlikte kullanın.
procedure OnCommandOther(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo;
AResponseInfo: TIdHTTPResponseInfo);
begin
if SameText(ARequestInfo.Command, 'OPTIONS') then
begin
AResponseInfo.CustomHeaders.Add('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
AResponseInfo.ResponseNo := 204;
end;
end;