mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-21 07:39:30 -10:00
* AcceptEncodingModule.cs: don't cause nullref if there's no <mono.aspnet> section and the module is loaded. svn path=/trunk/mcs/; revision=28935
47 lines
979 B
C#
47 lines
979 B
C#
//
|
|
// AcceptEncodingModule.cs
|
|
//
|
|
// Authors:
|
|
// Gonzalo Paniagua Javier ([email protected])
|
|
//
|
|
// (c) 2003 Ximian, Inc (http://www.ximian.com)
|
|
//
|
|
|
|
using System;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
using System.Web;
|
|
using Mono.Http.Configuration;
|
|
|
|
namespace Mono.Http.Modules
|
|
{
|
|
public class AcceptEncodingModule : IHttpModule
|
|
{
|
|
static readonly string configSection = "mono.aspnet/acceptEncoding";
|
|
AcceptEncodingConfig config;
|
|
|
|
public void Init (HttpApplication app)
|
|
{
|
|
app.BeginRequest += new EventHandler (CheckIfAddFilter);
|
|
}
|
|
|
|
public void Dispose ()
|
|
{
|
|
}
|
|
|
|
void CheckIfAddFilter (object sender, EventArgs args)
|
|
{
|
|
HttpApplication app = (HttpApplication) sender;
|
|
HttpRequest request = app.Request;
|
|
HttpResponse response = app.Response;
|
|
|
|
if (config == null)
|
|
config = (AcceptEncodingConfig) app.Context.GetConfig (configSection);
|
|
|
|
if (config != null)
|
|
config.SetFilter (response, request.Headers ["Accept-Encoding"]);
|
|
}
|
|
}
|
|
}
|
|
|