Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Doc #510

Merged
merged 48 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
1f364ad
Merge pull request #475 from YangSen-qn/http3
xwen-winnie Dec 10, 2021
ef8169f
change uc query retry host order
Jul 19, 2023
bc3f3dc
Merge branch 'master' of YangSen-qn:qiniu/android-sdk into remove-reg…
Jul 20, 2023
112ff06
change test case
Jul 21, 2023
8193846
change test case
Jul 24, 2023
a052eb6
Merge branch 'master' of YangSen-qn:qiniu/android-sdk into remove-reg…
Jul 27, 2023
027d9ba
change mvn_push
Jul 31, 2023
47f87a6
update test token
Jul 31, 2023
21fff24
change gradle.properties: config jvm
Aug 1, 2023
5f060f7
change test case
Aug 2, 2023
4600249
Merge branch 'master' of YangSen-qn:qiniu/android-sdk into fix-publish
Aug 2, 2023
13ba1e5
update mvn_push.gradle
Aug 2, 2023
8608aa2
update test case
Aug 2, 2023
5d73445
version to 8.6.0
Aug 7, 2023
4ddce97
Merge branch 'fix-publish'
Aug 7, 2023
0f28b16
change publish
Oct 9, 2023
8a0b360
fix zone add createZonesInfo
Oct 11, 2023
06c6ae7
update android gradle plugin
Oct 11, 2023
ae58017
Merge branch 'master' of YangSen-qn:qiniu/android-sdk into fixzone
Oct 12, 2023
99a8f69
change publish
Oct 12, 2023
54c3003
add Cache - part 1
Oct 12, 2023
64d0057
auto zone support disk cache
Oct 19, 2023
b876c6b
optimize upload run
Oct 20, 2023
0d746d3
change test case
Oct 20, 2023
d96a439
change test token
Oct 20, 2023
cccaef5
change test case
Oct 20, 2023
546892a
Merge branch 'develop' of YangSen-qn:qiniu/android-sdk into query-dis…
Oct 24, 2023
21e3a11
Merge branch 'master' of YangSen-qn:qiniu/android-sdk into query-disk…
Oct 24, 2023
71e44cf
optimize some code
Oct 25, 2023
21f38d4
auto zone build date
Nov 3, 2023
79a7e12
cache timestamp unit to S
Nov 6, 2023
f48c2ca
uc query add host: uc.qiniuapi.com
Nov 13, 2023
e49840e
Merge branch 'master' of YangSen-qn:qiniu/android-sdk into uc-query-a…
Nov 13, 2023
fe832a3
change http scheme logic
Nov 16, 2023
16d92e0
change setHostScheme
Nov 16, 2023
5f22804
version to 8.7.0
Nov 23, 2023
4132537
Merge branch 'master' of YangSen-qn:qiniu/android-sdk
Nov 23, 2023
190d736
Merge branch 'master' of YangSen-qn:qiniu/android-sdk
Nov 27, 2023
e1ed20d
add some doc
Nov 27, 2023
3340c3e
add some doc
Nov 28, 2023
1e41eed
change some doc
Nov 29, 2023
b582e31
hidden some doc
Nov 30, 2023
7b27280
remove useless code
Nov 30, 2023
b091623
change javadoc
Nov 30, 2023
aa679cc
change doc
Nov 30, 2023
03355a3
optimize some code
Dec 7, 2023
5febea7
Merge branch 'multi-region'
Dec 7, 2023
1a697ee
delete useless code
Dec 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void testQuick(){
@Test
public void testNormal(){
Config.normal();
assertTrue(Config.uploadThreshold == 4*1024);
assertTrue(Config.uploadThreshold == 16*1024);
assertTrue(Config.interval == 10);
}

Expand Down
26 changes: 26 additions & 0 deletions library/src/main/java/com/qiniu/android/bigdata/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@

/**
* Created by long on 2017/7/25.
*
* @hidden
*/

public final class Configuration implements Cloneable {

/**
* pipelineHost
*/
public String pipelineHost = "https://pipeline.qiniu.com";

/**
* 请求 proxy
*/
public ProxyConfiguration proxy;


Expand All @@ -22,6 +31,18 @@ public final class Configuration implements Cloneable {
*/
public int responseTimeout = 10;

/**
* 构造函数
*/
public Configuration() {
}

/**
* Configuration copy
*
* @param config 待 copy 对象
* @return Configuration
*/
public static Configuration copy(Configuration config) {
if (config == null) {
return new Configuration();
Expand All @@ -33,6 +54,11 @@ public static Configuration copy(Configuration config) {
}
}

/**
* Configuration clone
*
* @return Configuration
*/
public Configuration clone() throws CloneNotSupportedException {
return (Configuration) super.clone();
}
Expand Down
114 changes: 110 additions & 4 deletions library/src/main/java/com/qiniu/android/bigdata/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,49 @@

/**
* Created by bailong on 15/11/12.
*
* @hidden
*/
public final class Client {
/**
* HTTP 请求头:Content-Type
*/
public static final String ContentTypeHeader = "Content-Type";

/**
* HTTP 请求默认的 MimeType
*/
public static final String DefaultMime = "application/octet-stream";

/**
* HTTP 请求 Json 的 MimeType
*/
public static final String JsonMime = "application/json";

/**
* HTTP 请求 FormMime 的 MimeType
*/
public static final String FormMime = "application/x-www-form-urlencoded";

private final UrlConverter converter;
private OkHttpClient httpClient;

/**
* 构造方法
*/
public Client() {
this(null, 10, 30, null, null);
}

/**
* 构造函数
*
* @param proxy 请求代理
* @param connectTimeout 请求建立连接超时时间
* @param responseTimeout 请求接收数据超时时间
* @param converter 请求 Url 拦截器
* @param dns 请求的 Dns 解析器
*/
public Client(ProxyConfiguration proxy, int connectTimeout, int responseTimeout, UrlConverter converter, final Dns dns) {
this.converter = converter;
OkHttpClient.Builder builder = new OkHttpClient.Builder();
Expand All @@ -71,9 +101,9 @@ public List<InetAddress> lookup(String hostname) throws UnknownHostException {
List<IDnsNetworkAddress> networkAddressList = DnsPrefetcher.getInstance().getInetAddressByHost(hostname);
if (networkAddressList != null && networkAddressList.size() > 0) {
List<InetAddress> inetAddressList = new ArrayList<>();
for (IDnsNetworkAddress networkAddress : networkAddressList){
for (IDnsNetworkAddress networkAddress : networkAddressList) {
InetAddress address = null;
if (networkAddress.getIpValue() != null && (address = InetAddress.getByName(networkAddress.getIpValue())) != null){
if (networkAddress.getIpValue() != null && (address = InetAddress.getByName(networkAddress.getIpValue())) != null) {
inetAddressList.add(address);
}
}
Expand Down Expand Up @@ -210,6 +240,15 @@ public void run() {
});
}

/**
* 异步请求
*
* @param requestBuilder 请求构造器
* @param headers 请求头
* @param upToken 上传 Token
* @param totalSize 请求体大小
* @param complete 结束回调
*/
public void asyncSend(final Request.Builder requestBuilder, StringMap headers, final UpToken upToken,
final long totalSize, final CompletionHandler complete) {
if (headers != null) {
Expand Down Expand Up @@ -259,13 +298,39 @@ public void onResponse(Call call, okhttp3.Response response) throws IOException
});
}

/**
* 异步 POST 请求
*
* @param url 请求 url
* @param body 请求 body
* @param headers 请求 header
* @param upToken 上传 token
* @param totalSize 请求总大小
* @param progressHandler 请求进度回调
* @param completionHandler 结束回调
* @param c 取消回调
*/
public void asyncPost(String url, byte[] body,
StringMap headers, final UpToken upToken,
final long totalSize, ProgressHandler progressHandler,
CompletionHandler completionHandler, UpCancellationSignal c) {
asyncPost(url, body, 0, body.length, headers, upToken, totalSize, progressHandler, completionHandler, c);
}

/**
* 异步 POST 请求
*
* @param url 请求 Url
* @param body 请求体
* @param offset 请求体偏移量
* @param size 请求体大小
* @param headers 请求 Header
* @param upToken 上传 Token
* @param totalSize 请求体总大小
* @param progressHandler 进度回调
* @param completionHandler 完成回调
* @param c 取消回调
*/
public void asyncPost(String url, byte[] body, int offset, int size,
StringMap headers, final UpToken upToken,
final long totalSize, ProgressHandler progressHandler,
Expand Down Expand Up @@ -295,6 +360,16 @@ public void asyncPost(String url, byte[] body, int offset, int size,
asyncSend(requestBuilder, headers, upToken, totalSize, completionHandler);
}

/**
* 异步表单请求
*
* @param url 请求 Url
* @param args 请求参数
* @param upToken 上传的 Token
* @param progressHandler 进度回调
* @param completionHandler 完成回答
* @param c 取消回调
*/
public void asyncMultipartPost(String url,
PostArgs args,
final UpToken upToken,
Expand Down Expand Up @@ -343,12 +418,27 @@ public void accept(String key, Object value) {
asyncSend(requestBuilder, null, upToken, totalSize, completionHandler);
}

/**
* 异步 GET 请求
*
* @param url 请求 Url
* @param headers 请求 Header
* @param upToken 上传的 Token
* @param completionHandler 请求完成回调
*/
public void asyncGet(String url, StringMap headers, final UpToken upToken,
CompletionHandler completionHandler) {
Request.Builder requestBuilder = new Request.Builder().get().url(url);
asyncSend(requestBuilder, headers, upToken, 0, completionHandler);
}

/**
* 同步 GET 请求
*
* @param url 请求 Url
* @param headers 请求 Header
* @return ResponseInfo
*/
public ResponseInfo syncGet(String url, StringMap headers) {
Request.Builder requestBuilder = new Request.Builder().get().url(url);
return send(requestBuilder, headers);
Expand Down Expand Up @@ -379,8 +469,15 @@ public void accept(String key, Object value) {
return buildResponseInfo(res, tag.ip, tag.duration, null, 0);
}

public ResponseInfo syncMultipartPost(String url, PostArgs args,
final UpToken upToken) {
/**
* 同步表单请求
*
* @param url 请求 Url
* @param args 请求参数
* @param upToken 上传 Token
* @return ResponseInfo
*/
public ResponseInfo syncMultipartPost(String url, PostArgs args, final UpToken upToken) {
RequestBody file;
long totalSize;
if (args.file != null) {
Expand Down Expand Up @@ -414,6 +511,15 @@ public void accept(String key, Object value) {
return syncSend(requestBuilder, null, upToken, totalSize);
}

/**
* 同步请求
*
* @param requestBuilder 请求构造器
* @param headers 请求 Header
* @param upToken 上传的 Token
* @param totalSize 请求体大小
* @return ResponseInfo
*/
public ResponseInfo syncSend(final Request.Builder requestBuilder, StringMap headers,
final UpToken upToken, final long totalSize) {
if (headers != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

/**
* 定义请求完成后续动作的处理接口
*
* @hidden
*/
public interface CompletionHandler {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

/**
* 定义请求参数列表
*
* @hidden
*/
public final class PostArgs {
/**
Expand All @@ -29,4 +31,10 @@ public final class PostArgs {
*/
public String mimeType;

/**
* 构造函数
*/
public PostArgs() {
}

}
Loading
Loading