P
poi
I want to do an HTTP "GET" against a remote web server, and make sure
that I get data back with gzip so the transfer is as fast as possible.
It seems like gzip encoding only works with a "POST", and I can't
"POST".
This throws an exception
"An unhandled exception of type 'System.Net.ProtocolViolationException'
occurred in system.dll
Additional information: Content-Length cannot be set for a non-write
operation."
wR = (HttpWebRequest)WebRequest.Create( myUri );
wR.Timeout = 3000;
wR.UserAgent = "SiteSee 1.0";
wR.Method = "GET";
wR.ContentType = "application/x-www-form-urlencoded";
wR.AllowWriteStreamBuffering = false;
wR.KeepAlive = true;
wR.ProtocolVersion = HttpVersion.Version11;
wR.SendChunked = true;
wR.TransferEncoding = "gzip";
wR.ContentLength = 200000;
HttpWebResponse webResponse = (HttpWebResponse)wR.GetResponse();
System.Text.Encoding defaultEncoding =
System.Text.Encoding.GetEncoding(1252);
StreamReader responseStream = new StreamReader(
webResponse.GetResponseStream() , defaultEncoding );
string siteResponse = responseStream.ReadToEnd();
webResponse.Close();
responseStream.Close();
that I get data back with gzip so the transfer is as fast as possible.
It seems like gzip encoding only works with a "POST", and I can't
"POST".
This throws an exception
"An unhandled exception of type 'System.Net.ProtocolViolationException'
occurred in system.dll
Additional information: Content-Length cannot be set for a non-write
operation."
wR = (HttpWebRequest)WebRequest.Create( myUri );
wR.Timeout = 3000;
wR.UserAgent = "SiteSee 1.0";
wR.Method = "GET";
wR.ContentType = "application/x-www-form-urlencoded";
wR.AllowWriteStreamBuffering = false;
wR.KeepAlive = true;
wR.ProtocolVersion = HttpVersion.Version11;
wR.SendChunked = true;
wR.TransferEncoding = "gzip";
wR.ContentLength = 200000;
HttpWebResponse webResponse = (HttpWebResponse)wR.GetResponse();
System.Text.Encoding defaultEncoding =
System.Text.Encoding.GetEncoding(1252);
StreamReader responseStream = new StreamReader(
webResponse.GetResponseStream() , defaultEncoding );
string siteResponse = responseStream.ReadToEnd();
webResponse.Close();
responseStream.Close();