我正在尝试向网站发送请求以从中获取一些数据。但是,响应是垃圾字符,例如:
Ì 3ú¢¸<N¤@H±ü>§#Fe®¡+K·fÐcıaOqâò;'Êù!°â<rº\¼YDóß1K`òúüb¨ÑTcíÆ
这只发生在有数据的休息时,错误也能正常工作。响应应该是这样的(来自浏览器请求): {"d":[{"__type":"CalendarTransport:http:...","activityId":2662,"activityImportIdentifier":null,"activityType":1,"allDay":false,"attendanceMode":1,....
这是我的代码
try
{
HttpsURLConnection httpsURLConnection;
httpsURLConnection = (HttpsURLConnection) new URL("https", redacted, redacted).openConnection();
try
{
httpsURLConnection.setRequestMethod("POST");
}
catch (Exception e)
{
Log.d(TAG, "doInBackground: oh no (3) it's a " + e.toString());
}
httpsURLConnection.setRequestProperty("Accept-Charset", "*/*");
httpsURLConnection.setRequestProperty("Accept-Encoding", "gzip, deflate, br");
httpsURLConnection.setRequestProperty("Connection", "keep-alive");
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
httpsURLConnection.setRequestProperty("Cookie", new DomainCookies(redacted).toRequestHeader());
httpsURLConnection.setDoOutput(true);
httpsURLConnection.setDoInput(true);
OutputStream os = httpsURLConnection.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8");
osw.write(redacted);
osw.flush();
osw.close();
os.close();
浏览器可以得到很好的响应,它一定是我正在做的事情(或 android,但我怀疑)
慕尼黑的夜晚无繁华
相关分类