当前位置: 首页>>代码示例>>Java>>正文


Java Client类代码示例

本文整理汇总了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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:a.java

示例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;
}
 
开发者ID:luania,项目名称:witchpot,代码行数:34,代码来源:Auth.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:NetworkHelper.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:36,代码来源:HttpURLConnectionImpl.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:32,代码来源:ResumeUploader.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:6,代码来源:UploadManager.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:5,代码来源:FormUploader.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:5,代码来源:j.java


注:本文中的com.qiniu.android.http.Client类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。