Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#Changelog

## 7.0.1
## 7.0.2 (2014-10-29)

### 修正
* 修正response info isOK 的判断,避免返回部分数据时判断错误

## 7.0.1 (2014-10-24)

### 增加
* 增加maven 一键发布
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/com/qiniu/android/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created by bailong on 14/10/8.
*/
public final class Config {
public static final String VERSION = "7.0.1";
public static final String VERSION = "7.0.2";

public static final String UP_HOST = "upload.qiniu.com";
public static final String UP_HOST_BACKUP = "up.qiniu.com";
Expand Down
30 changes: 18 additions & 12 deletions library/src/main/java/com/qiniu/android/http/ResponseHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ private static ResponseInfo buildResponseInfo(int statusCode, Header[] headers,
}
}
}
} else{
if (reqId==null){
err = "remote is not qiniu server!";
}
}

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

private static JSONObject buildJsonResp(byte[] body) {
try {
String str = new String(body, Config.CHARSET);
return new JSONObject(str);
} catch (JSONException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
private static JSONObject buildJsonResp(byte[] body) throws Exception {

String str = new String(body, Config.CHARSET);
return new JSONObject(str);
}

@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
ResponseInfo info = buildResponseInfo(statusCode, headers, null, null);
JSONObject obj = null;
Exception exception = null;
try {
obj = buildJsonResp(responseBody);
} catch (Exception e) {
exception = e;
}

ResponseInfo info = buildResponseInfo(statusCode, headers, null, exception);
Log.i("qiniu----success", info.toString());
JSONObject obj = buildJsonResp(responseBody);

completionHandler.complete(info, obj);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public boolean isCancelled() {
}

public boolean isOK() {
return statusCode == 200;
return statusCode == 200 && error == null && reqId != null;
}

public boolean isNetworkBroken() {
Expand All @@ -50,7 +50,7 @@ public boolean isServerError() {
}

public boolean needRetry() {
return isNetworkBroken() || isServerError() || statusCode == 406;
return isNetworkBroken() || isServerError() || statusCode == 406 || (statusCode == 200 && error != null);
}

public String toString() {
Expand Down