Skip to content

Commit 60645d6

Browse files
committed
part body return
1 parent 5631e36 commit 60645d6

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#Changelog
22

3-
## 7.0.1
3+
## 7.0.2 (2014-10-29)
4+
5+
### 修正
6+
* 修正response info isOK 的判断,避免返回部分数据时判断错误
7+
8+
## 7.0.1 (2014-10-24)
49

510
### 增加
611
* 增加maven 一键发布

library/src/main/java/com/qiniu/android/common/Config.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Created by bailong on 14/10/8.
55
*/
66
public final class Config {
7-
public static final String VERSION = "7.0.1";
7+
public static final String VERSION = "7.0.2";
88

99
public static final String UP_HOST = "upload.qiniu.com";
1010
public static final String UP_HOST_BACKUP = "up.qiniu.com";

library/src/main/java/com/qiniu/android/http/ResponseHandler.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ private static ResponseInfo buildResponseInfo(int statusCode, Header[] headers,
5757
}
5858
}
5959
}
60+
} else{
61+
if (reqId==null){
62+
err = "remote is not qiniu server!";
63+
}
6064
}
6165

6266
if (statusCode == 0) {
@@ -66,23 +70,25 @@ private static ResponseInfo buildResponseInfo(int statusCode, Header[] headers,
6670
return new ResponseInfo(statusCode, reqId, xlog, err);
6771
}
6872

69-
private static JSONObject buildJsonResp(byte[] body) {
70-
try {
71-
String str = new String(body, Config.CHARSET);
72-
return new JSONObject(str);
73-
} catch (JSONException e) {
74-
e.printStackTrace();
75-
} catch (UnsupportedEncodingException e) {
76-
e.printStackTrace();
77-
}
78-
return null;
73+
private static JSONObject buildJsonResp(byte[] body) throws Exception {
74+
75+
String str = new String(body, Config.CHARSET);
76+
return new JSONObject(str);
7977
}
8078

8179
@Override
8280
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
83-
ResponseInfo info = buildResponseInfo(statusCode, headers, null, null);
81+
JSONObject obj = null;
82+
Exception exception = null;
83+
try {
84+
obj = buildJsonResp(responseBody);
85+
} catch (Exception e) {
86+
exception = e;
87+
}
88+
89+
ResponseInfo info = buildResponseInfo(statusCode, headers, null, exception);
8490
Log.i("qiniu----success", info.toString());
85-
JSONObject obj = buildJsonResp(responseBody);
91+
8692
completionHandler.complete(info, obj);
8793
}
8894

library/src/main/java/com/qiniu/android/http/ResponseInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public boolean isCancelled() {
3838
}
3939

4040
public boolean isOK() {
41-
return statusCode == 200;
41+
return statusCode == 200 && error == null && reqId != null;
4242
}
4343

4444
public boolean isNetworkBroken() {
@@ -50,7 +50,7 @@ public boolean isServerError() {
5050
}
5151

5252
public boolean needRetry() {
53-
return isNetworkBroken() || isServerError() || statusCode == 406;
53+
return isNetworkBroken() || isServerError() || statusCode == 406 || (statusCode == 200 && error != null);
5454
}
5555

5656
public String toString() {

0 commit comments

Comments
 (0)