TsgcHTTPServer › 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 için tetiklenir (PUT, DELETE, OPTIONS, PATCH, TRACE...). Hangi fiilin kullanıldığını öğrenmek için ARequestInfo.Command'ı ve hedef URI için ARequestInfo.Document'i inceleyin; tıpkı OnCommandGet'te olduğu gibi AResponseInfo.ContentText/ContentStream, ContentType ve ResponseNo'yu doldurun. Bu olayı işlemek, GET/POST ötesindeki fiilleri kabul eden REST uç noktalarını uygulamanın olağan yoludur; istek ayrıca yetkilendirme incelemesi de gerektirdiğinde bunu 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