You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#if NETFRAMEWORK
using System; using System.Collections.Generic; using System.Web;
namespace Apewer.Web.HttpProxy {
/// <summary></summary>
sealed class HttpModule : IHttpModule {
/// <summary></summary>
public void Dispose() { }
/// <summary></summary>
public void Init(HttpApplication context) { context.PreSendRequestHeaders += new EventHandler(ByContext); }
/// <summary></summary>
void ByContext(object sender, EventArgs e) { var context = HttpContext.Current; if (context == null) return;
var keys = new List<string>(); keys.AddRange(context.Response.Headers.AllKeys); if (keys.Contains("Server")) context.Response.Headers.Remove("Server"); if (keys.Contains("X-Powered-By")) context.Response.Headers.Remove("X-Powered-By"); }
/// <summary></summary>
void ByApplication(object sender, EventArgs e) { var app = sender as HttpApplication; if (app == null) return; if (app.Request == null) return; if (app.Request.IsLocal == false) return; if (app.Context == null) return; if (app.Context.Response == null) return; if (app.Context.Response.Headers == null) return; var headers = app.Context.Response.Headers; app.Context.Response.Headers.Remove("Server"); }
}
}
#endif
|