當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。