TsgcWebSocketHTTPServer › Olaylar › OnCommandOther

OnCommandOther Olay

HTTP sunucusu GET, POST veya HEAD dışında bir yöntem aldığında tetiklenir (PUT, DELETE, OPTIONS, PATCH...).

Sözdizimi

property OnCommandOther: TIdHTTPCommandEvent;
// TIdHTTPCommandEvent = procedure(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo) of object

Varsayılan Değer

—

Remarks

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.

Örnek


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;

Olaylara Dön