Answer the question
In order to leave comments, you need to log in
What could be the reasons that when reading the response to a POST request (in Java) I get hieroglyphs?
Good day.
When reading the answer, I get the body in hieroglyphs.
I understand that the answer immediately suggests itself - the problem is in the encoding. But I have already tried all the encodings, purely for the test and for fun (after the main popular ones).
More specifically:
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true); // пробовал передавать параметры как в теле запроса так и в параметрах в строке
connection.setRequestProperty("Host", HOST);
connection.setRequestProperty("Origin", ORIGIN);
connection.setRequestProperty("Accept-Charset", CHARSET); //CHARSET = "UTF-8";
connection.setRequestProperty("Content-Type", CONTENT_TYPE); //"application/x-www-form-urlencoded;charset=" + CHARSET;
connection.setRequestProperty("Accept-Encoding", ACCEPT_ENCODING); //"gzip, deflate"
connection.setRequestProperty("Accept-Language", ACCEPT_LANGUAGE); //"ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4"
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), CHARSET));
while ((line = reader.readLine()) != null)
{
result.append(line);
result.append("\n");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question