Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 107
Registered: ‎10-06-2010
My Device: Not Specified

GZIP Compression: Incorrect header check with MDS Connection

Hi Guys,

 

I have a wierd issue the using GZIP compression.

 

I download data from server using RESTful WCF services. The data is compressed by IIS with GZIP encoding.

 

I am using standard GZIP decompress module to decompress the data stream received from HTTP connection.

 

Now, If the application is connecting to the server using Direct TCP connection, GZIPInputStream reads data without any problem. But if the application is connecting to the server using MDS connection, it throws the IO Exceptin with Incorrect Header Check error message. I guess the BES server is decoding data before supplying to the device.

 

How do we work around with this problem?

 

Many thanks

 

Nitin

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: GZIP Compression: Incorrect header check with MDS Connection

Are you setting the "accept" header correctly for the request?

 

Should be something like this:

 

httpConnection.setRequestProperty("Accept-Encoding","gzip, deflate");

 

 

Developer
Posts: 107
Registered: ‎10-06-2010
My Device: Not Specified

Re: GZIP Compression: Incorrect header check with MDS Connection

Well I am setting accept header as

 

connection.setRequestProperty("Accept-Encoding", "gzip");

 

Do I need the "deflate" in the property? My concern is, the problem only occurs if MDS connection.

 

Nitin

Developer
Posts: 107
Registered: ‎10-06-2010
My Device: Not Specified

Re: GZIP Compression: Incorrect header check with MDS Connection

OK, I found a work around - I am not sure if it is the correct solution!

 

Check the response header by using

connection.getHeaderField(HttpProtocolConstants.HEADER_CONTENT_ENCODING)

 

and if the field contains the gzip then read the response using GZIP Stream otherwise use the standard Input Stream.

 

Any comments would be very much appriciated.

 

Many thanks

Nitin

Regular Visitor
Posts: 1
Registered: ‎06-20-2011
My Device: BlackBerry Torch
My Carrier: Vodacom

Re: GZIP Compression: Incorrect header check with MDS Connection

This excerpt seems to answer your question:

 

http://docs.blackberry.com/en/developers/deliverables/4305/BlackBerry_Browser-4.6.0-US.pdf
(p. 10)


"Compress content resources using GZIP. The benefit is reduced if a user browses through the BlackBerry MDS ConnectionService or the BlackBerry® Internet Service Browsing network gateway. These network gateways will uncompress thecomponents before they reach the wireless network in order to preprocess them and repackage them more efficiently fortransmission. However, when content is accessed over WAP or Wi-Fi® connections, using GZIP will reduce network traffic.Using GZIP can also improve transmission over wired networks."