Question Using WebClient for imitation of brawser

j0sur

New member
Joined
Jun 22, 2012
Messages
3
Programming Experience
3-5
Hello,
I need to imitate some brawser using .net framework's classes. I think, that it can be done by WebClient, but I need to set my custom header like
VB.NET:
Accept-Encoding: gzip, deflate
and in this case I'll get encoded data. How can I decode it? Sanx a lot and sorry for my English.
 
Easier done with HttpWebRequest, here you can set AutomaticDecompression property. For manual decompression you can use DeflateStream/GZipStream.
 
An alternative can also be to inherit a class from WebClient and override GetWebRequest method, where you set AutomaticDecompression for the underlying HttpWebReqest.
 
Easier done with HttpWebRequest, here you can set AutomaticDecompression property. For manual decompression you can use DeflateStream/GZipStream.
But if I will use AutomaticDecompression I need to know which encoding will be used. How can I get encoding type in this case?
 
Request the compression type you want.
 
The previous reply was a bit hasty, actually DecompressionMethods is a flags enumeration, the values can be combined as bitwise flags, so you can specify both values using bitwise Or operator (AutomaticDecompression = gzip Or deflate). Also note that when you set AutomaticDecompression the request Accept-Encoding header is set automatically.
 
Back
Top