Skip to content

Commit 74161b3

Browse files
committed
Merge pull request #177 from simon-liubin/res_ok
返回值json 、reqId 判断
2 parents 0a90f6d + edf2f25 commit 74161b3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/com/qiniu/http/Response.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ private Response(com.squareup.okhttp.Response response, int statusCode, String r
6666
static Response create(com.squareup.okhttp.Response response, String address, double duration) {
6767
String error = null;
6868
int code = response.code();
69-
String reqId = response.header("X-Reqid");
69+
String reqId = null;
7070

7171
byte[] body = null;
7272
if (ctype(response).equals(Client.JsonMime)) {
73+
reqId = response.header("X-Reqid");
74+
reqId = (reqId == null) ? null : reqId.trim();
7375
try {
7476
body = response.body().bytes();
7577
if (response.code() >= 400 && !StringUtils.isNullOrEmpty(reqId) && body != null) {
@@ -112,7 +114,7 @@ private static String ctype(com.squareup.okhttp.Response response) {
112114
}
113115

114116
public boolean isOK() {
115-
return statusCode == 200 && error == null;
117+
return statusCode == 200 && error == null && reqId != null && reqId.length() > 0;
116118
}
117119

118120
public boolean isNetworkBroken() {

0 commit comments

Comments
 (0)