C# 클래스 Common.HttpCompress.HttpModule

An HttpModule that hooks onto the Response.Filter property of the current request and tries to compress the output, based on what the browser supports

This HttpModule uses classes that inherit from CompressingFilter. We already support gzip and deflate (aka zlib), if you'd like to add support for compress (which uses LZW, which is licensed), add in another class that inherits from HttpFilter to do the work.

This module checks the Accept-Encoding HTTP header to determine if the client actually supports any notion of compression. Currently, we support the deflate (zlib) and gzip compression schemes. I chose to not implement compress because it uses lzw which requires a license from Unisys. For more information about the common compression types supported, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 for details.

상속: IHttpModule
파일 보기 프로젝트 열기: rabbal/Mvc5

공개 메소드들

메소드 설명
GetFilterForScheme ( string schemes, Stream output, Settings prefs ) : CompressingFilter

Get ahold of a CompressingFilter for the given encoding scheme. If no encoding scheme can be found, it returns null.

See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3 for details on how clients are supposed to construct the Accept-Encoding header. This implementation follows those rules, though we allow the server to override the preference given to different supported algorithms. I'm doing this as I would rather give the server control over the algorithm decision than the client. If the clients send up * as an accepted encoding with highest quality, we use the preferred algorithm as specified in the config file.

비공개 메소드들

메소드 설명
CompressContent ( object sender, EventArgs e ) : void

EventHandler that gets ahold of the current request context and attempts to compress the output.

GetQuality ( string acceptEncodingValue ) : float
IHttpModule ( ) : void

Implementation of IHttpModule

Currently empty. Nothing to really do, as I have no member variables.

IHttpModule ( System.Web.HttpApplication context ) : void

Init the handler and fulfill IHttpModule

This implementation hooks the ReleaseRequestState and PreSendRequestHeaders events to figure out as late as possible if we should install the filter. Previous versions did not do this as well.

IsBinaryFile ( System.Web.HttpApplication app ) : bool

메소드 상세

GetFilterForScheme() 공개 정적인 메소드

Get ahold of a CompressingFilter for the given encoding scheme. If no encoding scheme can be found, it returns null.
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3 for details on how clients are supposed to construct the Accept-Encoding header. This implementation follows those rules, though we allow the server to override the preference given to different supported algorithms. I'm doing this as I would rather give the server control over the algorithm decision than the client. If the clients send up * as an accepted encoding with highest quality, we use the preferred algorithm as specified in the config file.
public static GetFilterForScheme ( string schemes, Stream output, Settings prefs ) : CompressingFilter
schemes string
output Stream
prefs Settings
리턴 CompressingFilter