Hello. I send a request to the server and should get Json from it, but I get an answer with incomprehensible content:

4M  

X \ ? @ eqI / x} ׉ ۽ I ^ & ^ ح \ t ko Izk E _ '\ V 뻿 ه 9 ªTM + m 0X ̆ihʔ "qw m O { B ! U - e Tt d Y ࢔ 3 $ U ׳ z. @. ' & ݊ F բ S s ڥ- d9T M AJ 3 J iD4a } \ 2 / F | "G eSiX AcP i" ns b _z 橳 Rq 3Tg A w7 (ֶ $ = (0ph mV q ܦ 0 E nKn Ik T! 3> c w - ~ V` < 1fQ
At first I thought it was a matter of encodings, but even by the bytes I could not decipher the answer. The answer line often contains the character number 65533. Tell me where to look for the error.

  • four
    There are suspicions that this is a concise answer. Try editing Accept-Encoding in the request header. - Russtam 8:36 pm
  • You are absolutely right!!! - Jorik
  • @Russtam add answer - strangeqargo 9:54 pm

1 answer 1

As written by Russtam: the server sends a compressed response. For unzipping I used the following code:

  DataInputStream inStream = new DataInputStream(reqConn.getInputStream()); StringBuffer buffer = new StringBuffer(); GZIPInputStream gzip = new GZIPInputStream(inStream); InputStreamReader readerGzip = new InputStreamReader(gzip); BufferedReader bufReader = new BufferedReader(readerGzip); String reddd; while ((reddd = bufReader.readLine()) != null){ buffer.append(reddd); }