【问题标题】:Android Server response special chars ��������������V*�IAndroid 服务器响应特殊字符 ����������������V*�I
【发布时间】:2017-10-15 21:15:58
【问题描述】:

我的 Android 响应有问题。我检查了这台服务器的每一步,但我找不到解决方案。以下是详细信息:

网址: https://XXX/public/api/versions/published/2/1408 方法:获取

请求头:

Status  Complete
Response Code   200 OK
Protocol    HTTP/1.1
SSL TLSv1.2 (TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256)
Method  GET
Kept Alive  No
Content-Type    application/json

标头响应:

Connection: Keep-Alive
Accept-Encoding: gzip
User-Agent: okhttp/3.4.2

预期响应:

{
    "platform": "Android",
    "number": "5.5.3",
    "force_update": false
}

Android 收到响应:

05-16 14:09:40.500 12368-12425/com.screens D/OkHttp: --> GET https://XXX/public/api/versions/published/2/1408 http/1.1
05-16 14:09:40.500 12368-12425/com.screens D/OkHttp: --> END GET
05-16 14:09:40.700 12368-12425/com.screens W/System.err: org.json.JSONException: Value ��������������Kn� of type java.lang.String cannot be converted to JSONObject

服务器 ssl_protocols: TLSv1 TLSv1.1 TLSv1.2;

服务器字符集: UTF-8

Android Http 客户端库: 改造 2.3.0

【问题讨论】:

  • 您可能使用了错误的编码。
  • and accept all Certs 你没有任何安全保障。 不要那样做!
  • 在哪里?在我的服务器或我的应用程序中? @SLaks “并接受所有证书”-> 仅用于测试 :( 什么都没有
  • 要么。您需要在两端使用相同的编码(应该几乎总是 UTF8)。您需要了解 Unicode 编码的工作原理。
  • 在尝试提出更多问题之前,请阅读How do I ask a good question?

标签: android ssl server certificate response


【解决方案1】:

您收到的是 Gziped 响应,但您的应用无法解析它。

确保应用支持压缩响应。

【讨论】:

    猜你喜欢
    • 2015-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-14
    • 2010-11-30
    • 2011-08-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多