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 8080749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:30:29+00:00 2026-06-05T16:30:29+00:00

I am a little confused about Accept-Encoding . I have Web Service which would

  • 0

I am a little confused about Accept-Encoding. I have Web Service which would accept compressed file submission using POST method. I have added code below which look for Accept-Encoding: gzip and decompress submitted file. The problem is with a files which are submitted from internet browsers. Request headers contain gzip but file is not actually compressed. Maybe someone could help to understand how to detect is file actually compressed?

var httpPostedFile = httpRequest.Files[0];
var contentLength = httpPostedFile.ContentLength;
var buffer = new byte[contentLength];
httpPostedFile.InputStream.Read(buffer, 0, contentLength);

const string acceptEncoding = "Accept-Encoding";
if (httpRequest.Headers[acceptEncoding] != null && httpRequest.Headers[acceptEncoding].Contains("gzip"))
{

  buffer = Decompress(buffer);
}

 static byte[] Decompress(byte[] gzip)
        {            
            using (var stream = new GZipStream(new MemoryStream(gzip), CompressionMode.Decompress))
            {
                const int size = 4096;
                var buffer = new byte[size];
                using (var memory = new MemoryStream())
                {
                    int count;
                    do
                    {
                        count = stream.Read(buffer, 0, size);
                        if (count > 0)
                        {
                            memory.Write(buffer, 0, count);
                        }
                    }
                    while (count > 0);
                    return memory.ToArray();
                }
            }
        }
  • 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-06-05T16:30:31+00:00Added an answer on June 5, 2026 at 4:30 pm

    Accept-Encoding indicates what encodings the client accepts.

    The encoding of a given request is specified using Transfer-Encoding and Content-Encoding, but note that these will always apply to the whole request body, not just part of a multipart payload.

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

Sidebar

Related Questions

I am a little confused about how to handle a web service result in
I am a little confused about when do I have to serialize objects using
I'm a little confused about render, not quite sure which path it chooses to
I'm a little confused about the MVVM pattern which i'm combining with PRISM. In
I'm a little confused about clean-up order when you're using PThreads with regard to
I'm a little confused about which jQuery method and/or selectors to use when trying
I'm a little confused about using release vs. debug versions of a dll for
I'm a little confused about how to do something that I thought would be
I am a little confused about the benefits or conc using scriptmanager with ajax
I'm a little confused about how EGit workes. I have an existing git repository

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.