Skip to content

Commit 2e0836a

Browse files
committed
Merge pull request #91 from longbai/upcdn-via
Upcdn via
2 parents 7f356e9 + 646ac2c commit 2e0836a

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,17 @@ private static ResponseInfo buildResponseInfo(int statusCode, Header[] headers,
6262
String reqId = null;
6363
String xlog = null;
6464
String ip = null;
65+
String xvia = null;
6566
if (headers != null) {
6667
for (Header h : headers) {
6768
if ("X-Reqid".equals(h.getName())) {
6869
reqId = h.getValue();
6970
} else if ("X-Log".equals(h.getName())) {
7071
xlog = h.getValue();
72+
} else if ("X-Via".equals(h.getName())){
73+
xvia = h.getValue();
74+
} else if ("X-Px".equals(h.getName())){
75+
xvia = h.getValue();
7176
}
7277
}
7378
}
@@ -102,7 +107,7 @@ private static ResponseInfo buildResponseInfo(int statusCode, Header[] headers,
102107
statusCode = ResponseInfo.NetworkError;
103108
}
104109

105-
return new ResponseInfo(statusCode, reqId, xlog, host, ip, duration, err);
110+
return new ResponseInfo(statusCode, reqId, xlog, xvia, host, ip, duration, err);
106111
}
107112

108113
private static JSONObject buildJsonResp(byte[] body) throws Exception {
@@ -121,15 +126,15 @@ public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
121126
exception = e;
122127
}
123128
ResponseInfo info = buildResponseInfo(statusCode, headers, null, host, duration, exception);
124-
Log.i("qiniu----success", info.toString());
129+
Log.i("upload----success", info.toString());
125130
completionHandler.complete(info, obj);
126131
}
127132

128133
@Override
129134
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
130135
double duration = (System.currentTimeMillis() - reqStartTime) / 1000.0;
131136
ResponseInfo info = buildResponseInfo(statusCode, headers, responseBody, host, duration, error);
132-
Log.i("qiniu----failed", info.toString());
137+
Log.i("upload----failed", info.toString());
133138
completionHandler.complete(info, null);
134139
}
135140

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public final class ResponseInfo {
2323
* 七牛日志扩展头
2424
*/
2525
public final String xlog;
26+
/**
27+
* cdn日志扩展头
28+
*/
29+
public final String xvia;
2630
/**
2731
* 错误信息
2832
*/
@@ -40,28 +44,29 @@ public final class ResponseInfo {
4044
*/
4145
public final String ip;
4246

43-
public ResponseInfo(int statusCode, String reqId, String xlog, String host, String ip, double duration, String error) {
47+
public ResponseInfo(int statusCode, String reqId, String xlog, String xvia, String host, String ip, double duration, String error) {
4448
this.statusCode = statusCode;
4549
this.reqId = reqId;
4650
this.xlog = xlog;
51+
this.xvia = xvia;
4752
this.host = host;
4853
this.duration = duration;
4954
this.error = error;
5055
this.ip = ip;
5156
}
5257

5358
public static ResponseInfo cancelled() {
54-
return new ResponseInfo(Cancelled, "", "", "", "", 0, "cancelled by user");
59+
return new ResponseInfo(Cancelled, "", "", "", "", "", 0, "cancelled by user");
5560
}
5661

5762
public static ResponseInfo invalidArgument(String message) {
58-
return new ResponseInfo(InvalidArgument, "", "", "", "", 0,
63+
return new ResponseInfo(InvalidArgument, "","", "", "", "", 0,
5964
message);
6065
}
6166

6267

6368
public static ResponseInfo fileError(Exception e) {
64-
return new ResponseInfo(InvalidFile, "", "", "", "",
69+
return new ResponseInfo(InvalidFile, "","", "", "", "",
6570
0, e.getMessage());
6671
}
6772

@@ -90,7 +95,7 @@ public boolean needRetry() {
9095
}
9196

9297
public String toString() {
93-
return String.format(Locale.ENGLISH, "{ResponseInfo:%s,status:%d, reqId:%s, xlog:%s, host:%s, ip:%s, duration:%f s, error:%s}",
94-
super.toString(), statusCode, reqId, xlog, host, ip, duration, error);
98+
return String.format(Locale.ENGLISH, "{ResponseInfo:%s,status:%d, reqId:%s, xlog:%s, xvia:%s, host:%s, ip:%s, duration:%f s, error:%s}",
99+
super.toString(), statusCode, reqId, xlog, xvia, host, ip, duration, error);
95100
}
96101
}

0 commit comments

Comments
 (0)