Skip to content

Commit 691d6e3

Browse files
committed
fix client output info
1 parent 90ace81 commit 691d6e3

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/com/qiniu/auth/Client.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,16 @@ protected Object doInBackground(Object... objects) {
9191
try {
9292
HttpResponse resp = roundtrip(mHttpRequest);
9393
int statusCode = resp.getStatusLine().getStatusCode();
94-
if (statusCode == 401) { // android 2.3 will not response
95-
return new Exception("unauthorized!");
96-
}
97-
byte[] data = EntityUtils.toByteArray(resp.getEntity());
94+
String xl = resp.getFirstHeader("X-Log").getValue();
95+
96+
if (statusCode == 401) return new Exception("unauthorized!"); // android 2.3 will not response
97+
if (xl.contains("invalid BlockCtx")) return new Exception(xl);
9898

99-
if (statusCode / 100 != 2) {
100-
if (data.length == 0) {
101-
String xlog = resp.getFirstHeader("X-Log").getValue();
102-
if (xlog.length() > 0) {
103-
return new Exception(xlog);
104-
}
105-
return new Exception(resp.getStatusLine().getReasonPhrase());
106-
}
107-
return new Exception(new String(data));
108-
}
109-
return data;
99+
byte[] data = EntityUtils.toByteArray(resp.getEntity());
100+
if (statusCode / 100 == 2) return data;
101+
if (data.length > 0) return new Exception(new String(data));
102+
if (xl.length() > 0) return new Exception(xl);
103+
return new Exception(resp.getStatusLine().getStatusCode() + ":" + resp.getStatusLine().getReasonPhrase());
110104
} catch (IOException e) {
111105
e.printStackTrace();
112106
return e;

0 commit comments

Comments
 (0)