David
Thu Dec 15 15:52:51 CST 2005
Accept-Encoding is a request header sent by the client to the server. So, a
server-side application can definitely check for the header.
Content-Encoding is a response header sent by the server to the client. A
server-side application cannot see the header at all -- you need a
client-side application to check.
Thus, the server-side application can, as a client, make an HTTP request to
itself containing the Accept-Encoding header and check if the response has a
Content-Encoding header.
In my original response, I have already given the location in IIS
configuration to check. Please read documentation on how this works.
--
//David
IIS
http://blogs.msdn.com/David.Wang
This posting is provided "AS IS" with no warranties, and confers no rights.
//
"vsr" <vsr@discussions.microsoft.com> wrote in message
news:8D0A9702-393E-495B-B269-12260988894B@microsoft.com...
> thanks for the info, i dont think i can go with the first option in
> myscenario, the only thing left is checking iis configuration whether
> compression is enabled or not, how can we check this? where exactly we can
> look for this value?
>
> And in fact when verified the headers i could see "Accept-Encoding" with
> values "gzip" and "deflate" , but i am little confused where to check the
> "content-encoding" header.
>
> "David Wang [Msft]" wrote:
>
>> How you add "Accept-Encoding" depends on the network library you use to
>> make
>> the HTTP request.
>>
>> There is nothing you can do at the IIS level other than to enable
>> Compression.
>>
>> I think you misunderstand how compression works in reality. When you
>> enable
>> Compression in IIS, it does not mean that IIS sends all responses as
>> compressed. Rather, it means that responses are compressed only for
>> clients
>> that say "I support compression". And client say that by sending the
>> "Accept-Encoding" header on the request.
>>
>> Obviously, if a client does not support compression and IIS sends
>> compressed
>> response, it looks like garbage to it... this is why enabling Compression
>> in
>> IIS simply gives IIS the *option* to send compressed responses, not
>> right.
>> You will find that most things in HTTP are like this -- mutually
>> negotiated
>> options.
>>
>> Thus, the only ways to know if compression is enabled is to:
>> 1. Pragmatically script a client to send a request that say "I support
>> compression" and see what IIS responds with
>> 2. Programmatically read IIS configuration to determine if appropriate
>> compression scheme is enabled.
>>
>> --
>> //David
>> IIS
>>
http://blogs.msdn.com/David.Wang
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>> //
>>
>> "vsr" <vsr@discussions.microsoft.com> wrote in message
>> news:6CE801BB-C56E-4F5C-9873-DA9643207E11@microsoft.com...
>> > How do you add this from code? or do we need to add this at IIS level?
>> > if
>> > IIS
>> > level how can we do ? any sample please?
>> >
>> > "David Wang [Msft]" wrote:
>> >
>> >> Yes, you need to manually add the Accept-Encoding header.
>> >>
>> >> In order for requests to be compressed, it must have the
>> >> Accept-Encoding
>> >> header. If you do not send the Accept-Encoding header, IIS will not
>> >> compress
>> >> the response, regardless if compression is enabled or not.
>> >>
>> >> IIS will automatically add Content-Encoding header on the response if
>> >> it
>> >> compresses it.
>> >>
>> >> --
>> >> //David
>> >> IIS
>> >>
http://blogs.msdn.com/David.Wang
>> >> This posting is provided "AS IS" with no warranties, and confers no
>> >> rights.
>> >> //
>> >> "vsr" <vsr@discussions.microsoft.com> wrote in message
>> >> news:ACCE3EE5-D0E0-4FB8-B5DA-B24404DC54FF@microsoft.com...
>> >> Do we need to add the header "Accept-Encoding" manually? or by default
>> >> when
>> >> "Content-Encoding" comes when the compression is enabled? Cant i
>> >> directly
>> >> get
>> >> the Request.Headers("Content-Encoding") value and check for "gzip" and
>> >> "deflate"?
>> >>
>> >> "David Wang [Msft]" wrote:
>> >>
>> >> > You can either:
>> >> > 1. send a test HTTP request to the server with "Accept-Encoding:
>> >> > gzip,deflate\r\n" and see whether Content-Encoding: header comes
>> >> > back
>> >> > 2. Use either ABO/ADSI/WMI (or the .Net counterparts to ADSI/WMI) to
>> >> > read
>> >> > W3SVC/Filters/Compression/gzip and W3SVC/Filters/Compression/deflate
>> >> > nodes
>> >> > to check if they are enabled.
>> >> >
>> >> > --
>> >> > //David
>> >> > IIS
>> >> >
http://blogs.msdn.com/David.Wang
>> >> > This posting is provided "AS IS" with no warranties, and confers no
>> >> rights.
>> >> > //
>> >> > "vsr" <vsr@discussions.microsoft.com> wrote in message
>> >> > news:A6118B61-A532-41A7-8B4F-FAC53F61E7D8@microsoft.com...
>> >> > I wanted to know in the application whether IIS Compression is
>> >> > enabled
>> >> > or
>> >> > not
>> >> > and switch the code accordingly, is there any way to track whether
>> >> > Compression is enabled or not in vb.net program.
>> >> >
>> >> >
>> >> >
>> >>
>> >>
>> >>
>>
>>
>>
>>