Hi, Java developers. I get a response with headers and body as shown below, but when I try to unpack it using the following code, it fails with this exception:
java.io.IOException: Not in GZIP format
Answer:
HTTP / 1.1 200 OK
Content-Type: text / xml; charset = utf-8
Content-Encoding: gzip
Server: Jetty (6.1.x)
▼ UMs ¢ 0► = 7┐ép? ╙6-C╚ $ ╢gΩ ↓ ╟ ± ╪ ₧ ∟zS╨╓╓ ♦ $ FÆ╒ ÷ ▀G┬╚╞8N≤╤Cf ° ►╦█╖╗o ↨æJÄ + `: ↓ 2
♣ »└√S▬L &? ∙ ┬_) U╔ | ♣% ûíyk_à \, æ] hⁿ? ▀xΓ∟o╜4 ♫ ù \ #MAHG? ┤ (Q¶╞⌡▌Ç? ▼ ô [7Fí¼↔ φ☻I% ╓╣Z♂? ¿↨F; x | ♦ o / A╬ ♣ ╘≡∞─≤╝╘U ∙ ♥ 0☺æ? | J% à {(éUmHµ% σl┴ ▼ Ç9 ♣ ┌Ç ? ♫ ╡5╠yë ~ ├╜ ♦ íi ♫ ╥╧
╬û? ▓ε? ╞┼ → RtGqè ₧ ójWë ♫ ╩∞j05├╞┘ |> ┘º ∙ ↑ j╪2┐ | = ÷ ²
eY \ ╛P? # 5wÑqc╙τ ♦ ▓½Θt £ 6q∩? ┌4┼t ♠ ↕ = 7æƒ╙? ╟ | ♂; ║) ∩ ÷ ≈═ ^ ╛ {v⌂┌∞◄> 6ä╝ |
The code:
byte[] b= IOUtils.toByteArray(sock.getInputStream()); ByteArrayInputStream bais = new ByteArrayInputStream(b); GZIPInputStream gzis = new GZIPInputStream(bais); InputStreamReader reader = new InputStreamReader(gzis); BufferedReader in = new BufferedReader(reader); String readed; while ((readed = in.readLine()) != null) { System.out.println("read: "+readed); }
Please inform.
Thanks,
Pradeep
java gzip
Bill
source share