0

I have a response filter where I use the following code to get the HTML string from the byte array.

public override void Write(byte[] buffer, int offset, int count) {
    var html = Encoding.UTF8.GetString(buffer);
    // do stuff
}

if I set doDynamicCompression to true in web.config like the code below, the string looks like this

  <system.webServer>
    <urlCompression doDynamicCompression="true" />

Is there a secure way of getting the HTML string that works with compression and without?

4

1 に答える 1

1

を使用GZipStreamしてコンテンツを解凍することもできますが、応答フィルターで結果を処理しているため、もはや圧縮されていません (ただし、ヘッダーには圧縮していると書かれています)。そのため、圧縮の作業を行う必要があります。また。

これは、自動的に行われる利点をすべて失うことを意味します。

そのため、圧縮を自分で処理する独自のフィルターを作成することをお勧めします (これで見つけた 1 つの落とし穴は、フィルターがフラッシュされたときに使用する gzipstream をフラッシュしたくないということですが、それでもフラッシュする必要があります)。出力ストリーム)。

(大量のテキストがチャンクで送信され、チャンクが文字の途中で終了する場合、指定されたコードはどのように処理しますか?)

于 2012-08-18T20:27:51.940 に答える