2014-09-03 46 views
1

1)什麼是可選的skipHeaders參數在ServiceStack的EndRequest方法的目的是什麼?或者換句話說,什麼時候發生了什麼skipHeaderstruefalseServiceStack的EndRequest方法中可選「skipHeaders」參數的用途是什麼?

this.UncaughtExceptionHandlers.Add((req, res, operationName, ex) => { 
     res.Write("Error: {0}: {1}".Fmt(ex.GetType().Name, ex.Message)); 
     res.EndRequest(skipHeaders: true); 
    }); 

2)下面顯示的用法是否正確(我想拒絕來自反向代理的請求)?

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] 
    public sealed class DenyRequestFromReverseProxyAttribute : RequestFilterAttribute 
    { 
     public override void Execute(IRequest req, IResponse res, object requestDto) 
     { 
      if (req.Headers.AllKeys.Contains("X-Forwarded-For")) 
      { 
       res.StatusCode = (int)HttpStatusCode.Forbidden; 
       res.Write("Forbidden - For internal use only."); 
       res.EndRequest(skipHeaders: true); 
      } 
     } 
    } 

回答

3

它決定是否編寫Config.GlobalResponseHeaders HTTP頭。如果你已經寫過你想要的迴應流skipHeaders:true

相關問題