Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7547799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:32:42+00:00 2026-05-30T09:32:42+00:00

I am sending and receiving web requests with HttpWebRequest. After a response it is

  • 0

I am sending and receiving web requests with HttpWebRequest.

After a response it is usually gzip’d content encoding.
Some computers will receive deflate encoding.
Some other computers will receive identity encoding.

I have it set up to read gzip and deflate encoding but am unsure how to read identity encoding.

string ReturnString = "";

HttpWebRequest HttpWebRequest = (HttpWebRequest)WebRequest.Create(URL);
HttpWebRequest.ProtocolVersion = Version.Parse("1.1");
WebHeaderCollection WebHeaderCollection = HttpWebRequest.Headers;
HttpWebRequest.Accept = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
WebHeaderCollection.Add("Accept-Language: en-us");
WebHeaderCollection.Add("Accept-Encoding: gzip, deflate");
HttpWebRequest.KeepAlive = true;
HttpWebResponse HttpWebResponse = (HttpWebResponse)HttpWebRequest.GetResponse();
using (var mem = HttpWebResponse.GetResponseStream())
{
    if (HttpWebResponse.ContentEncoding.ToLower().Contains("gzip"))
    {
        using (var gzip = new GZipStream(mem, CompressionMode.Decompress))
        {
            using (var reader = new StreamReader(gzip))
            {
                ReturnString = reader.ReadToEnd();
            }
        }
    }
    else if (HttpWebResponse.ContentEncoding.ToLower().Contains("deflate"))
    {
        using (var gzip = new DeflateStream(mem, CompressionMode.Decompress))
        {
            using (var reader = new StreamReader(gzip))
            {
                ReturnString = reader.ReadToEnd();
            }
        }
    }
}
WebHeaderCollection ResponseHeaders = HttpWebResponse.Headers;
HttpWebResponse.Close();

Edit:
Another PC received “Transfer-Encoding: chunked” and no Content Encoding, which if I read it right it should replace Content Encoding. http://en.wikipedia.org/wiki/Chunked_transfer_encoding.

Is there no way to catch any type of encoding?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:32:43+00:00Added an answer on May 30, 2026 at 9:32 am

    RFC:

    identity

    The default (identity) encoding; the use of no transformation
    whatsoever.
    This content-coding is used only in the Accept-
    Encoding header, and SHOULD NOT be used in the Content-Encoding
    header.

    As for your edit: you should not have to care about the response being chunked: using string resp = new StreamReader(response.GetResponseStream()).ReadToEnd() should give you all the response data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am sending a request to webservice and am receiving correct response from web
I need to provide email sending and receiving capabilities within my java web-application. Think
I'm developing simple Windows Service sending and receiving data from remote web service. I
I've been working with sending and receiving email through various web-mail clients using WatiN,
A 3rd party site sends its notifications after my web application has completed some
Can anyone recommend an article on sending and receiving JSON to an asp.net web
I'm struggling sending POST data to a server and receiving the correct response. I
I'm creating a web page that user can send pm , receive it,add contact,response
I am currently sending and receiving SIP messages across a network. When I want
I have an Arduino sending and receiving instructions with a Python script via a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.