diff --git a/library/src/main/java/com/qiniu/android/http/ResponseHandler.java b/library/src/main/java/com/qiniu/android/http/ResponseHandler.java index e8d28ace7..35a5e8daf 100644 --- a/library/src/main/java/com/qiniu/android/http/ResponseHandler.java +++ b/library/src/main/java/com/qiniu/android/http/ResponseHandler.java @@ -62,12 +62,17 @@ private static ResponseInfo buildResponseInfo(int statusCode, Header[] headers, String reqId = null; String xlog = null; String ip = null; + String xvia = null; if (headers != null) { for (Header h : headers) { if ("X-Reqid".equals(h.getName())) { reqId = h.getValue(); } else if ("X-Log".equals(h.getName())) { xlog = h.getValue(); + } else if ("X-Via".equals(h.getName())){ + xvia = h.getValue(); + } else if ("X-Px".equals(h.getName())){ + xvia = h.getValue(); } } } @@ -102,7 +107,7 @@ private static ResponseInfo buildResponseInfo(int statusCode, Header[] headers, statusCode = ResponseInfo.NetworkError; } - return new ResponseInfo(statusCode, reqId, xlog, host, ip, duration, err); + return new ResponseInfo(statusCode, reqId, xlog, xvia, host, ip, duration, err); } private static JSONObject buildJsonResp(byte[] body) throws Exception { @@ -121,7 +126,7 @@ public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { exception = e; } ResponseInfo info = buildResponseInfo(statusCode, headers, null, host, duration, exception); - Log.i("qiniu----success", info.toString()); + Log.i("upload----success", info.toString()); completionHandler.complete(info, obj); } @@ -129,7 +134,7 @@ public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { double duration = (System.currentTimeMillis() - reqStartTime) / 1000.0; ResponseInfo info = buildResponseInfo(statusCode, headers, responseBody, host, duration, error); - Log.i("qiniu----failed", info.toString()); + Log.i("upload----failed", info.toString()); completionHandler.complete(info, null); } diff --git a/library/src/main/java/com/qiniu/android/http/ResponseInfo.java b/library/src/main/java/com/qiniu/android/http/ResponseInfo.java index 89c7d6754..74daa71d8 100644 --- a/library/src/main/java/com/qiniu/android/http/ResponseInfo.java +++ b/library/src/main/java/com/qiniu/android/http/ResponseInfo.java @@ -23,6 +23,10 @@ public final class ResponseInfo { * 七牛日志扩展头 */ public final String xlog; + /** + * cdn日志扩展头 + */ + public final String xvia; /** * 错误信息 */ @@ -40,10 +44,11 @@ public final class ResponseInfo { */ public final String ip; - public ResponseInfo(int statusCode, String reqId, String xlog, String host, String ip, double duration, String error) { + public ResponseInfo(int statusCode, String reqId, String xlog, String xvia, String host, String ip, double duration, String error) { this.statusCode = statusCode; this.reqId = reqId; this.xlog = xlog; + this.xvia = xvia; this.host = host; this.duration = duration; this.error = error; @@ -51,17 +56,17 @@ public ResponseInfo(int statusCode, String reqId, String xlog, String host, Stri } public static ResponseInfo cancelled() { - return new ResponseInfo(Cancelled, "", "", "", "", 0, "cancelled by user"); + return new ResponseInfo(Cancelled, "", "", "", "", "", 0, "cancelled by user"); } public static ResponseInfo invalidArgument(String message) { - return new ResponseInfo(InvalidArgument, "", "", "", "", 0, + return new ResponseInfo(InvalidArgument, "","", "", "", "", 0, message); } public static ResponseInfo fileError(Exception e) { - return new ResponseInfo(InvalidFile, "", "", "", "", + return new ResponseInfo(InvalidFile, "","", "", "", "", 0, e.getMessage()); } @@ -90,7 +95,7 @@ public boolean needRetry() { } public String toString() { - return String.format(Locale.ENGLISH, "{ResponseInfo:%s,status:%d, reqId:%s, xlog:%s, host:%s, ip:%s, duration:%f s, error:%s}", - super.toString(), statusCode, reqId, xlog, host, ip, duration, error); + return String.format(Locale.ENGLISH, "{ResponseInfo:%s,status:%d, reqId:%s, xlog:%s, xvia:%s, host:%s, ip:%s, duration:%f s, error:%s}", + super.toString(), statusCode, reqId, xlog, xvia, host, ip, duration, error); } }