Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried to make HttpWebRequeset object with gzip-compressed request stream as follow

C#
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
   request.Method = "POST";
   request.ContentType = "application/x-www-form-urlencoded";
   request.ContentLength = data.Length;
   using (Stream writeStream = request.GetRequestStream())
          {
              using (var zipStream = new GZipStream(writeStream, CompressionMode.Compress))
              {
                  UTF8Encoding encoding = new UTF8Encoding();
                  byte[] bytes = encoding.GetBytes(data);

                  zipStream.Write(bytes, 0, bytes.Length);
              }
          }
    try
  {

      request.Headers.Add(HttpRequestHeader.ContentEncoding, "gzip");
      request.Headers.Add("Accept-Encoding", "gzip,deflate");
       response = (HttpWebResponse)request.GetResponse();
   }
catch(Exception e){

}

But I have request abortted exception. Please help me to fix this problem.
Posted
Comments
Ziee-M 31-Jul-14 7:44am    
try removing using (for tests reasons only), mabe the object is destroyed before actualy being used.
cradion 1-Aug-14 3:18am    
Thanks, It stops loading at request.GetResponse() method.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900