當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpClients.createMinimal方法代碼示例

本文整理匯總了Java中org.apache.http.impl.client.HttpClients.createMinimal方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpClients.createMinimal方法的具體用法?Java HttpClients.createMinimal怎麽用?Java HttpClients.createMinimal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.impl.client.HttpClients的用法示例。


在下文中一共展示了HttpClients.createMinimal方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cipherPassword

import org.apache.http.impl.client.HttpClients; //導入方法依賴的package包/類
/**
 * Cipher password of Bilibili account, use for username and password login which feature is not finished yet.
 *
 * @param password password of Bilibili account
 * @return ciphered password
 */
public static String cipherPassword(String password) throws Exception {
    String hash;
    String key;
    //獲取 hash 和 key
    try (CloseableHttpClient closeableHttpClient = HttpClients.createMinimal()) {
        JSONObject jsonObject = JSON.parseObject(
                EntityUtils.toString(
                        closeableHttpClient.execute(
                                new HttpGet("http://passport.bilibili.com/login?act=getkey")
                        ).getEntity()
                )
        );
        hash = jsonObject.getString("hash");
        key = jsonObject.getString("key");
    }

    //計算密碼密文
    RSAPublicKey rsaPublicKey = new RSAPublicKeyImpl(
            Base64.getDecoder().decode(
                    key.replace("-----BEGIN PUBLIC KEY-----", "")
                            .replace("-----END PUBLIC KEY-----", "")
                            .replace("\n", "")
                            .getBytes()
            )
    );
    Cipher cipher = Cipher.getInstance("RSA");
    cipher.init(Cipher.ENCRYPT_MODE, rsaPublicKey);
    return new String(
            Base64.getEncoder().encode(
                    cipher.doFinal((hash + password).getBytes())
            )
    );
}
 
開發者ID:czp3009,項目名稱:bilibili-live-api,代碼行數:40,代碼來源:LiveDanMuSender.java

示例2: createClient

import org.apache.http.impl.client.HttpClients; //導入方法依賴的package包/類
@Override
protected HttpClient createClient() {
  return HttpClients.createMinimal();
}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:5,代碼來源:MinimalHttpClientInstrumentationTest.java


注:本文中的org.apache.http.impl.client.HttpClients.createMinimal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。