Skip to content

Commit 83173e8

Browse files
author
jordanqin
committed
update qcloud sdk to 1.5.57
1 parent 4814292 commit 83173e8

18 files changed

+128
-160
lines changed

QCloudFoundation/foundation/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
minSdkVersion 15
88
targetSdkVersion 28
99

10-
versionCode 10556
11-
versionName "1.5.56"
10+
versionCode 10557
11+
versionName "1.5.57"
1212

1313
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
1414

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/CallMetricsListener.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ public class CallMetricsListener extends EventListener {
6969
private long readResponseBodyStartTime;
7070
private long readResponseBodyTookTime;
7171

72-
/**
73-
* domainName inetAddressList connectAddress 都可能是空值
74-
*/
75-
private List<InetAddress> inetAddressList;
72+
private List<InetAddress> dnsInetAddressList;
73+
private InetAddress connectAddress;
7674

7775
private long requestBodyByteCount;
7876
private long responseBodyByteCount;
@@ -100,7 +98,7 @@ public void dnsEnd(Call call, String domainName, List<InetAddress> inetAddressLi
10098
ipList.append("}");
10199
QCloudLogger.i(QCloudHttpClient.HTTP_LOG_TAG, "dns: " + domainName + ":" + ipList.toString());
102100
dnsLookupTookTime += System.nanoTime() - dnsStartTime;
103-
this.inetAddressList = inetAddressList;
101+
this.dnsInetAddressList = inetAddressList;
104102
}
105103

106104
@Override
@@ -114,12 +112,14 @@ public void connectStart(Call call, InetSocketAddress inetSocketAddress, Proxy p
114112
public void connectEnd(Call call, InetSocketAddress inetSocketAddress, Proxy proxy, Protocol protocol) {
115113
super.connectEnd(call, inetSocketAddress, proxy, protocol);
116114
connectTookTime += System.nanoTime() - connectStartTime;
115+
connectAddress = inetSocketAddress.getAddress();
117116
}
118117

119118
@Override
120119
public void connectFailed(Call call, InetSocketAddress inetSocketAddress, Proxy proxy, Protocol protocol, IOException ioe) {
121120
super.connectFailed(call, inetSocketAddress, proxy, protocol, ioe);
122121
connectTookTime += System.nanoTime() - connectStartTime;
122+
connectAddress = inetSocketAddress.getAddress();
123123
}
124124

125125
@Override
@@ -190,7 +190,8 @@ public void responseBodyEnd(Call call, long byteCount) {
190190
}
191191

192192
public void dumpMetrics(HttpTaskMetrics metrics) {
193-
metrics.remoteAddress = inetAddressList;
193+
metrics.recordConnectAddress(connectAddress);
194+
metrics.remoteAddress = dnsInetAddressList;
194195
metrics.dnsStartTimestamp += dnsStartTimestamp;
195196
metrics.dnsLookupTookTime += dnsLookupTookTime;
196197
metrics.connectStartTimestamp += connectStartTimestamp;
@@ -210,7 +211,7 @@ public void dumpMetrics(HttpTaskMetrics metrics) {
210211
}
211212

212213
public List<InetAddress> dumpDns() {
213-
return inetAddressList;
214+
return dnsInetAddressList;
214215
}
215216

216217
@NonNull
@@ -231,7 +232,8 @@ public String toString() {
231232
", readResponseHeaderTookTime=" + readResponseHeaderTookTime +
232233
", readResponseBodyTimestamp=" + readResponseBodyStartTimestamp +
233234
", readResponseBodyTookTime=" + readResponseBodyTookTime +
234-
", inetAddressList=" + inetAddressList +
235+
", inetAddressList=" + dnsInetAddressList +
236+
", connectAddress=" + connectAddress +
235237
", requestBodyByteCount=" + requestBodyByteCount +
236238
", responseBodyByteCount=" + responseBodyByteCount +
237239
'}';

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/HttpConstants.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
package com.tencent.qcloud.core.http;
2424

2525
public final class HttpConstants {
26+
/**
27+
* 腾讯云COS服务响应标识: 接收请求并返回响应的服务器的名称
28+
*/
29+
public static final String TENCENT_COS_SERVER = "tencent-cos";
2630

2731
public static final class ContentType {
2832

@@ -73,6 +77,8 @@ public static final class Header {
7377
public final static String DATE = "Date";
7478

7579
public final static String EXPECT = "Expect";
80+
81+
public final static String SERVER = "Server";
7682
}
7783

7884
public static final class RequestMethod {

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/HttpLoggingInterceptor.java

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,15 @@
2121
*/
2222
package com.tencent.qcloud.core.http;
2323

24-
import java.io.EOFException;
2524
import java.io.IOException;
26-
import java.nio.charset.Charset;
27-
import java.nio.charset.UnsupportedCharsetException;
2825
import java.util.concurrent.TimeUnit;
2926

3027
import okhttp3.Connection;
31-
import okhttp3.Headers;
3228
import okhttp3.Interceptor;
33-
import okhttp3.MediaType;
3429
import okhttp3.OkHttpClient;
3530
import okhttp3.Protocol;
3631
import okhttp3.Request;
37-
import okhttp3.RequestBody;
3832
import okhttp3.Response;
39-
import okhttp3.ResponseBody;
40-
import okhttp3.internal.http.HttpHeaders;
41-
import okhttp3.internal.platform.Platform;
42-
import okio.Buffer;
43-
import okio.BufferedSource;
44-
45-
import static okhttp3.internal.platform.Platform.INFO;
4633

4734
/**
4835
* An OkHttp interceptor which logs request and response information. Can be applied as an
@@ -54,8 +41,6 @@
5441
* fork from okhttp3.logging.
5542
*/
5643
final public class HttpLoggingInterceptor implements Interceptor {
57-
private static final Charset UTF8 = Charset.forName("UTF-8");
58-
5944
public enum Level {
6045
/**
6146
* No logs.
@@ -118,30 +103,6 @@ public interface Logger {
118103
void logRequest(String message);
119104
void logResponse(Response response, String message);
120105
void logException(Exception exception, String message);
121-
122-
/**
123-
* A {@link Logger} defaults output appropriate for the current platform.
124-
*/
125-
Logger DEFAULT = new Logger() {
126-
@Override
127-
public void logRequest(String message) {
128-
Platform.get().log(INFO, message, null);
129-
}
130-
131-
@Override
132-
public void logResponse(Response response, String message) {
133-
Platform.get().log(INFO, message, null);
134-
}
135-
136-
@Override
137-
public void logException(Exception exception, String message) {
138-
Platform.get().log(INFO, message, null);
139-
}
140-
};
141-
}
142-
143-
public HttpLoggingInterceptor() {
144-
this(Logger.DEFAULT);
145106
}
146107

147108
public HttpLoggingInterceptor(Logger logger) {

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/HttpTaskMetrics.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,10 @@ synchronized public HttpTaskMetrics merge(HttpTaskMetrics taskMetrics) {
319319
public String toString() {
320320
return new StringBuilder().append("Http Metrics: \n")
321321
.append("domain : ").append(domainName).append("\n")
322+
.append("connectAddress : ").append(connectAddress != null ? connectAddress.getHostAddress() : "null").append("\n")
322323
.append("retryCount : ").append(retryCount).append("\n")
323324
.append("isClockSkewedRetry : ").append(isClockSkewedRetry).append("\n")
324-
.append("dns : ").append(connectAddress != null ? connectAddress.getHostAddress() : "null").append("\n")
325+
.append("dns : ").append(remoteAddress != null ? remoteAddress : "null").append("\n")
325326
.append("fullTaskTookTime : ").append(fullTaskTookTime()).append("\n")
326327
.append("calculateMD5STookTime : ").append(calculateMD5STookTime()).append("\n")
327328
.append("signRequestTookTime : ").append(signRequestTookTime()).append("\n")

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/MultipartStreamRequestBody.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import com.tencent.qcloud.core.common.QCloudDigistListener;
3131
import com.tencent.qcloud.core.common.QCloudProgressListener;
32+
import com.tencent.qcloud.core.util.OkhttpInternalUtils;
3233

3334
import java.io.File;
3435
import java.io.IOException;
@@ -40,7 +41,6 @@
4041
import okhttp3.MediaType;
4142
import okhttp3.MultipartBody;
4243
import okhttp3.RequestBody;
43-
import okhttp3.internal.Util;
4444
import okio.BufferedSink;
4545
import okio.BufferedSource;
4646
import okio.Okio;
@@ -146,7 +146,7 @@ public void writeTo(BufferedSink sink) throws IOException {
146146
try {
147147
multipartBody.writeTo(sink);
148148
}finally {
149-
if(streamingRequestBody.countingSink != null)Util.closeQuietly(streamingRequestBody.countingSink);
149+
if(streamingRequestBody.countingSink != null) OkhttpInternalUtils.closeQuietly(streamingRequestBody.countingSink);
150150
}
151151
}
152152

@@ -243,8 +243,8 @@ public void writeTo(BufferedSink sink) throws IOException {
243243
}
244244
} finally {
245245

246-
if(inputStream != null) Util.closeQuietly(inputStream);
247-
if(source != null) Util.closeQuietly(source);
246+
if(inputStream != null) OkhttpInternalUtils.closeQuietly(inputStream);
247+
if(source != null) OkhttpInternalUtils.closeQuietly(source);
248248
}
249249
}
250250
}

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/OkHttpClientImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
package com.tencent.qcloud.core.http;
2424

2525
import com.tencent.qcloud.core.BuildConfig;
26-
import com.tencent.qcloud.core.http.interceptor.HttpMetricsInterceptor;
2726
import com.tencent.qcloud.core.http.interceptor.RetryInterceptor;
2827
import com.tencent.qcloud.core.http.interceptor.TrafficControlInterceptor;
2928

@@ -66,7 +65,7 @@ public void init(QCloudHttpClient.Builder b, HostnameVerifier hostnameVerifier,
6665
.readTimeout(b.socketTimeout, TimeUnit.MILLISECONDS)
6766
.writeTimeout(b.socketTimeout, TimeUnit.MILLISECONDS)
6867
.eventListenerFactory(mEventListenerFactory)
69-
.addNetworkInterceptor(new HttpMetricsInterceptor())
68+
// .addNetworkInterceptor(new HttpMetricsInterceptor())
7069
.addInterceptor(logInterceptor)
7170
.addInterceptor(new RetryInterceptor(b.retryStrategy))
7271
.addInterceptor(new TrafficControlInterceptor())

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/OkHttpLoggingUtils.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.tencent.qcloud.core.http;
22

3-
import com.tencent.qcloud.core.http.HttpLoggingInterceptor;
3+
import com.tencent.qcloud.core.util.OkhttpInternalUtils;
44

55
import java.io.EOFException;
66
import java.io.IOException;
@@ -15,7 +15,6 @@
1515
import okhttp3.RequestBody;
1616
import okhttp3.Response;
1717
import okhttp3.ResponseBody;
18-
import okhttp3.internal.http.HttpHeaders;
1918
import okio.Buffer;
2019
import okio.BufferedSource;
2120

@@ -48,7 +47,7 @@ public static void logResponse(Response response, long tookMs, HttpLoggingInterc
4847
logger.logResponse(response, headers.name(i) + ": " + headers.value(i));
4948
}
5049

51-
if (!logBody || !HttpHeaders.hasBody(response) || !hasResponseBody || isContentLengthTooLarge(contentLength)) {
50+
if (!logBody || !OkhttpInternalUtils.hasBody(response) || !hasResponseBody || isContentLengthTooLarge(contentLength)) {
5251
logger.logResponse(response, "<-- END HTTP");
5352
} else if (bodyEncoded(response.headers())) {
5453
logger.logResponse(response, "<-- END HTTP (encoded body omitted)");

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/OkHttpProxy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import com.tencent.qcloud.core.common.QCloudClientException;
2626
import com.tencent.qcloud.core.common.QCloudServiceException;
27+
import com.tencent.qcloud.core.util.OkhttpInternalUtils;
2728

2829
import java.io.IOException;
2930
import java.lang.reflect.Field;
@@ -34,7 +35,6 @@
3435
import okhttp3.OkHttpClient;
3536
import okhttp3.Request;
3637
import okhttp3.Response;
37-
import okhttp3.internal.Util;
3838

3939
public class OkHttpProxy<T> extends NetworkProxy<T> {
4040

@@ -109,7 +109,7 @@ protected HttpResult<T> executeHttpRequest(HttpRequest<T> httpRequest) throws QC
109109
}
110110
} finally {
111111
if(response != null && !selfCloseConverter) {
112-
Util.closeQuietly(response);
112+
OkhttpInternalUtils.closeQuietly(response);
113113
}
114114
}
115115

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/ResponseBodyConverter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
/**
3333
* 响应体转换器
34-
* @param <T>
3534
*/
3635
public abstract class ResponseBodyConverter<T> {
3736

0 commit comments

Comments
 (0)