3

I am using Apache mod_deflate to return compressed html from a webpage. It has reduced the generated page size from 3k down to 700 bytes.

How do I use HttpConnection in Blackberry to get the compressed page (i.e. only 700bytes instead of 3k)?

P.S. Trying to use the GZIPInputStream(inputStream) keeps returning an incorrect header check error.

nattyP
  • 309
  • 1
  • 2
  • 10
  • Asked another way: Does anyone have any success in sending php:gzencode data to Blackberry/Java:GZIPInputStream – nattyP Aug 12 '12 at 19:28

1 Answers1

0

As I understood you already tried to download and got non-compressed html page.

If so I think you should add "Accept-Encoding" header to your request (question on forum). Try:

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

Don't forget that you will get zipped data, so you need to unzip before using.

Also, as mentioned here, gzip/deflate is not so efficient when your traffic is going over BIS-B, BES. Because BB servers will encode/decode data to analyze it and make it more efficient fro transmission.

Eugen Martynov
  • 19,888
  • 10
  • 61
  • 114
  • Thanks. I have added it. Now I am getting "incorrect header check" from the line "data = IOUtilities.streamToBytes(new GZIPInputStream(httpInputStream));" – nattyP Aug 13 '12 at 07:20
  • Try using just gzip (deflate compression is not well defined). – symcbean Aug 13 '12 at 09:28
  • 1
    I got it to work. I am only using apache mod_deflate. In PHP, I am only using "ob_start('ob_gzhandler');". Working with gzencode required me to set a whole bunch of header values. I was then able to read the stream on BB using byte[] data = IOUtilities.streamToBytes(new GZIPInputStream(inputStream)), where inputStream = httpConnection.openInputStream(); BUT the setRequestProperty and getEncoding methods also did the trick. – nattyP Aug 14 '12 at 05:50
  • 1
    I would recommend you to post your solution and accept as answer. So people will have more detailed answer in future. – Eugen Martynov Aug 14 '12 at 05:57