@Azapro0

Почему не работают запросы?

Мой код:
class GetList extends AsyncTask<Void, Void, JSONObject>
{

	private Integer logLevel;

    public GetList(Integer logLevel)
	{
		this.logLevel = logLevel;
	}

    @Override
    protected JSONObject doInBackground(Void... voids)
	{
        JSONObject jsonObject = new JSONObject();
        try
		{
            URL url = new URL("https://127.0.0.1:5000/list/dom1k/124600/");
            HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
			connection.setRequestProperty("Content-Type", "text/xml; charset=utf-16");

            int responseCode = connection.getResponseCode();
            if (responseCode == HttpURLConnection.HTTP_OK)
			{
                BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                String inputLine;
                StringBuilder response = new StringBuilder();

                while ((inputLine = in.readLine()) != null)
				{
                    response.append(inputLine);
                }
                in.close();

                jsonObject = new JSONObject(response.toString());
            }
			else
			{
                Log.println(Log.ERROR, "PA", "GET request failed. Response code: " + responseCode);
            }

            connection.disconnect();
        }
		catch (Exception e)
		{
            e.printStackTrace();
        }

        return jsonObject;
    }

    @Override
    protected void onPostExecute(JSONObject result)
	{
        super.onPostExecute(result);
		Log.println(Log.DEBUG, "PA", result.toString());
    }
}


Когда я запускаю приложение по логам с сервера приходит пустой обьект
{}

А сервер видит это:
"\x16\x03\x01\x00û\x01\x00\x00÷\x03\x03E\x1b±ï\x04ìaFÔ7Ä\x1eÌ"®xÑ'ô\x16\x91\x86¿\x9a\x18j¸íd\x98W6 ¥i\x9fus®dWáw5'HÈ\x00\x1fD\x7f\x94Mölsê¸r\x90©\x1a­\x19\x02\x00"\x13\x01\x13\x02\x13\x03À+À,Ì©À/À0̨À\x09À"


Сервер работает правельно, тестил в браузере, и скриптом на python
  • Вопрос задан
  • 72 просмотра
Пригласить эксперта
Ответы на вопрос 1
LaRN
@LaRN
Senior Developer
Может в кодировке дело? Попробуйте вместо
charset=utf-16 установить charset=utf-8.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы