Skip to content

Commit 3b30dab

Browse files
authored
Merge pull request #232 from sxci/sent_size
设置上传请求的大小
2 parents f60326d + 3f10b35 commit 3b30dab

File tree

1 file changed

+13
-1
lines changed
  • library/src/main/java/com/qiniu/android/http

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,19 @@ private static ResponseInfo buildResponseInfo(okhttp3.Response response, String
168168

169169
HttpUrl u = response.request().url();
170170
return new ResponseInfo(json, code, reqId, response.header("X-Log"),
171-
via(response), u.host(), u.encodedPath(), ip, u.port(), duration, 0, error);
171+
via(response), u.host(), u.encodedPath(), ip, u.port(), duration, getContentLength(response), error);
172+
}
173+
174+
private static long getContentLength(okhttp3.Response response) {
175+
try {
176+
RequestBody body = response.request().body();
177+
if (body == null) {
178+
return 0;
179+
}
180+
return body.contentLength();
181+
} catch (Throwable t) {
182+
return -1;
183+
}
172184
}
173185

174186
private static void onRet(okhttp3.Response response, String ip, long duration,

0 commit comments

Comments
 (0)