本文整理汇总了Java中com.qiniu.android.http.Client类的典型用法代码示例。如果您正苦于以下问题:Java Client类的具体用法?Java Client怎么用?Java Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Client类属于com.qiniu.android.http包,在下文中一共展示了Client类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: a
import com.qiniu.android.http.Client; //导入依赖的package包/类
public ArrayList<KVPair<String>> a(ArrayList<KVPair<String>> arrayList) {
StringBuilder stringBuilder = new StringBuilder("OAuth ");
Iterator it = arrayList.iterator();
int i = 0;
while (it.hasNext()) {
KVPair kVPair = (KVPair) it.next();
if (i > 0) {
stringBuilder.append(',');
}
stringBuilder.append(kVPair.name).append("=\"").append(a((String) kVPair.value)).append(com.alipay.sdk.sys.a.e);
i++;
}
ArrayList<KVPair<String>> arrayList2 = new ArrayList();
arrayList2.add(new KVPair("Authorization", stringBuilder.toString()));
arrayList2.add(new KVPair("Content-Type", Client.FormMime));
return arrayList2;
}
示例2: signRequest
import com.qiniu.android.http.Client; //导入依赖的package包/类
/**
* 生成HTTP请求签名字符串
*
* @param urlString
* @param body
* @param contentType
* @return
*/
public String signRequest(String urlString, byte[] body, String contentType) {
URI uri = URI.create(urlString);
String path = uri.getRawPath();
String query = uri.getRawQuery();
Mac mac = createMac();
mac.update(StringUtils.utf8Bytes(path));
if (query != null && query.length() != 0) {
mac.update((byte) ('?'));
mac.update(StringUtils.utf8Bytes(query));
}
mac.update((byte) '\n');
if (body != null && body.length > 0 && !StringUtils.isNullOrEmpty(contentType)) {
if (contentType.equals(Client.FormMime)
|| contentType.equals(Client.JsonMime)) {
mac.update(body);
}
}
String digest = UrlSafeBase64.encodeToString(mac.doFinal());
return this.accessKey + ":" + digest;
}
示例3: getTextPost
import com.qiniu.android.http.Client; //导入依赖的package包/类
private HttpPost getTextPost(String str, ArrayList<KVPair<String>> arrayList) throws Throwable {
HttpPost httpPost = new HttpPost(str);
if (arrayList != null) {
StringPart stringPart = new StringPart();
stringPart.append(kvPairsToUrl(arrayList));
HttpEntity inputStreamEntity = stringPart.getInputStreamEntity();
inputStreamEntity.setContentType(Client.FormMime);
httpPost.setEntity(inputStreamEntity);
}
return httpPost;
}
示例4: newHttpEngine
import com.qiniu.android.http.Client; //导入依赖的package包/类
private HttpEngine newHttpEngine(String method, StreamAllocation streamAllocation,
RetryableSink requestBody, Response priorResponse) throws
MalformedURLException, UnknownHostException {
Request.Builder builder = new Request.Builder().url(Internal.instance.getHttpUrlChecked
(getURL().toString())).method(method, HttpMethod.requiresRequestBody(method) ?
EMPTY_REQUEST_BODY : null);
Headers headers = this.requestHeaders.build();
int size = headers.size();
for (int i = 0; i < size; i++) {
builder.addHeader(headers.name(i), headers.value(i));
}
boolean bufferRequestBody = false;
if (HttpMethod.permitsRequestBody(method)) {
if (this.fixedContentLength != -1) {
builder.header("Content-Length", Long.toString(this.fixedContentLength));
} else if (this.chunkLength > 0) {
builder.header("Transfer-Encoding", "chunked");
} else {
bufferRequestBody = true;
}
if (headers.get("Content-Type") == null) {
builder.header("Content-Type", Client.FormMime);
}
}
if (headers.get(Network.USER_AGENT) == null) {
builder.header(Network.USER_AGENT, defaultUserAgent());
}
Request request = builder.build();
OkHttpClient engineClient = this.client;
if (!(Internal.instance.internalCache(engineClient) == null || getUseCaches())) {
engineClient = this.client.clone().setCache(null);
}
return new HttpEngine(engineClient, request, bufferRequestBody, true, false,
streamAllocation, requestBody, priorResponse);
}
示例5: ResumeUploader
import com.qiniu.android.http.Client; //导入依赖的package包/类
ResumeUploader(Client client, Configuration config, File f, String key, UpToken token, final
UpCompletionHandler completionHandler, UploadOptions options, String recorderKey) {
this.client = client;
this.config = config;
this.f = f;
this.recorderKey = recorderKey;
this.size = (int) f.length();
this.key = key;
this.headers = new StringMap().put("Authorization", "UpToken " + token.token);
this.completionHandler = new UpCompletionHandler() {
public void complete(String key, ResponseInfo info, JSONObject response) {
if (ResumeUploader.this.file != null) {
try {
ResumeUploader.this.file.close();
} catch (IOException e) {
e.printStackTrace();
}
}
completionHandler.complete(key, info, response);
}
};
if (options == null) {
options = UploadOptions.defaultOptions();
}
this.options = options;
this.chunkBuffer = new byte[config.chunkSize];
this.contexts = new String[((int) ((long) (((this.size + Configuration.BLOCK_SIZE) - 1) /
Configuration.BLOCK_SIZE)))];
this.modifyTime = f.lastModified();
this.token = token;
}
示例6: UploadManager
import com.qiniu.android.http.Client; //导入依赖的package包/类
public UploadManager(Configuration config) {
this.config = config;
this.client = new Client(config.proxy, config.connectTimeout, config.responseTimeout,
config.urlConverter, config.dns);
}
示例7: upload
import com.qiniu.android.http.Client; //导入依赖的package包/类
static void upload(Client httpManager, Configuration config, byte[] data, String key, UpToken
token, UpCompletionHandler completionHandler, UploadOptions options) {
post(data, null, key, token, completionHandler, options, httpManager, config);
}
示例8: j
import com.qiniu.android.http.Client; //导入依赖的package包/类
public j(g gVar, Method method, int i, String str, byte[] bArr, boolean z) {
super(method, i, str, bArr, Client.FormMime, z);
this.g = gVar;
}