Results 1 to 2 of 2

Thread: Spring Android and GZIP Compression not being read correctly

  1. #1
    Join Date
    Aug 2004
    Location
    Allentown, PA
    Posts
    141

    Default 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. #2
    Join Date
    Oct 2012
    Posts
    1

    Default

    Quote 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);
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •