Announcement Announcement Module
Collapse
No announcement yet.
Spring Android and GZIP Compression not being read correctly Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Android and GZIP Compression not being read correctly

    I am writing an app that should be able to take advantage of a GZIPed response, however, when a GZIP response is detected, the following is thrown:

    08-01 11:32:58.620: E/AndroidRuntime(24027): Caused by:
    org.codehaus.jackson.JsonParseException: Illegal character ((CTRL-CHAR, code
    31)): only regular white space (\r, \n, \t) is allowed between tokens
    08-01 11:32:58.620: E/AndroidRuntime(24027): at [Source:
    org.apache.http.conn.EofSensorInputStream@40890828 ; line: 1, column: 2]


    The 0x31 is the ID1 character in a gziped response.

    I am wondering if the JSON parser is being invoked before the GZIP handler. Just a thought.

  • #2
    Originally posted by dmfrey View Post
    I am writing an app that should be able to take advantage of a GZIPed response, however, when a GZIP response is detected, the following is thrown:

    08-01 11:32:58.620: E/AndroidRuntime(24027): Caused by:
    org.codehaus.jackson.JsonParseException: Illegal character ((CTRL-CHAR, code
    31)): only regular white space (\r, \n, \t) is allowed between tokens
    08-01 11:32:58.620: E/AndroidRuntime(24027): at [Source:
    org.apache.http.conn.EofSensorInputStream@40890828 ; line: 1, column: 2]


    The 0x31 is the ID1 character in a gziped response.

    I am wondering if the JSON parser is being invoked before the GZIP handler. Just a thought.

    You have to decompress the response first:

    Header contentEncoding = response.getFirstHeader("Content-Encoding");
    if (contentEncoding != null && contentEncoding.getValue().equalsIgnoreCase("gzip" )) {
    InputStream instream = new GZIPInputStream(response.getEntity().getContent()) ;
    IOUtils.copy(instream, outstream);
    } else {
    response.getEntity().writeTo(outstream);
    }

    Comment

    Working...
    X