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

  • Home
  • SEARCH
  • 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 8236095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:02:30+00:00 2026-06-07T19:02:30+00:00

This is from a Answer on SO As to the GZIP compression, you shouldn’t

  • 0

This is from a Answer on SO

As to the GZIP compression, you shouldn’t do it yourself. Let the server do itself.

Fix your code to remove all manual attempts to compress the response, it should end up to basically look like this:

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String json = createItSomehow();
    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    response.getWriter().write(json);
}

Now the below from Apache Tomcat 7 configuration page for HTTP Connector

compression

The Connector may use HTTP/1.1 GZIP compression in an attempt to save
server bandwidth. The acceptable values for the parameter is “off”
(disable compression), “on” (allow compression, which causes text data
to be compressed), “force” (forces compression in all cases), or a
numerical integer value (which is equivalent to “on”, but specifies
the minimum amount of data before the output is compressed). If the
content-length is not known and compression is set to “on” or more
aggressive, the output will also be compressed. If not specified, this
attribute is set to “off”.

compressionMinSize

If compression is set to “on” then this attribute may be used to
specify the minimum amount of data before the output is compressed. If
not specified, this attribute is defaults to “2048”

This implied that when compression in set to on. The data will only be compressed if it is greater than 2084.

In my Android client I am using the following code to find if the data is gzip compressed or not

if ( entity.getContentEncoding() != null && "gzip".equalsIgnoreCase(entity.getContentEncoding().getValue())

My Question

Does Server also set the value of entity.getContentEncoding().getValue() when it compressed the data?

  • 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-07T19:02:31+00:00Added an answer on June 7, 2026 at 7:02 pm

    The server knows nothing about whatever entity is in your android app. Tomcat’s connector will set the Content-Encoding response header appropriately if gzip is in use.

    Also, your code is more complicated than it needs to be. You can just do this:

    if ( "gzip".equalsIgnoreCase(entity.getContentEncoding().getValue())
    

    …because there is no chance of an NPE.

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

Sidebar

Related Questions

I am using the accepted answer from this question . The relevant code is
I'm having trouble figuring out how to implement the code from this answer. Android:
In the code from this answer : $.validator.addMethod('lessThanEqual', function(value, element, param) { return this.optional(element)
Using the code from this answer: https://stackoverflow.com/a/9744961/514773 I've noticed that any time I enter:
I'm using the following code from this answer Sending email in .NET through Gmail
The code below is adapted from this answer function MessageClass() { var self =
I got the country iso by the code from this answer : TelephonyManager tm
From this answer: When is a C++ terminate handler the Right Thing(TM)? It would
I've just read this snippet from another answer : When you create a block
I just read this great answer from BalusC about how to upload files with

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.