java类com.mashape.unirest.http.options.Option的实例源码

TestWithProxiedEmbeddedServer.java 文件源码 项目:Bastion 阅读 27 收藏 0 点赞 0 评论 0
@BeforeClass
public static void setupProxying() {
    DnsResolver dnsResolver = prepareProxiedDnsResolver();
    DefaultSchemePortResolver schemePortResolver = prepareSchemePortResolver();
    BasicHttpClientConnectionManager connManager = prepareConnectionManager(dnsResolver, schemePortResolver);
    HttpClient httpClient = prepareHttpClient(connManager);
    originalHttpClient = (HttpClient) Options.getOption(Option.HTTPCLIENT);
    Unirest.setHttpClient(httpClient);
}
Unirest.java 文件源码 项目:unirest-android 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Set the connection timeout and socket timeout
 */
public static void setTimeouts(long connectionTimeout, long socketTimeout) {
    Options.setOption(Option.CONNECTION_TIMEOUT, connectionTimeout);
    Options.setOption(Option.SOCKET_TIMEOUT, socketTimeout);

    // Reload the client implementations
    Options.refresh();
}
Unirest.java 文件源码 项目:unirest-android 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Set default header
 */
@SuppressWarnings("unchecked")
public static void setDefaultHeader(String name, String value) {
    Object headers = Options.getOption(Option.DEFAULT_HEADERS);
    if (headers == null) {
        headers = new HashMap<String, String>();
    }
    ((Map<String, String>) headers).put(name, value);
    Options.setOption(Option.DEFAULT_HEADERS, headers);
}
ClientFactory.java 文件源码 项目:unirest-android 阅读 25 收藏 0 点赞 0 评论 0
public static HttpClient getHttpClient() {
    return (HttpClient) Options.getOption(Option.HTTPCLIENT);
}
ClientFactory.java 文件源码 项目:unirest-android 阅读 25 收藏 0 点赞 0 评论 0
public static CloseableHttpAsyncClient getAsyncHttpClient() {
    return (CloseableHttpAsyncClient) Options.getOption(Option.ASYNCHTTPCLIENT);
}
Unirest.java 文件源码 项目:unirest-android 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Set the HttpClient implementation to use for every synchronous request
 */
public static void setHttpClient(HttpClient httpClient) {
    Options.setOption(Option.HTTPCLIENT, httpClient);
}
Unirest.java 文件源码 项目:unirest-android 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Clear default headers
 */
public static void clearDefaultHeaders() {
    Options.setOption(Option.DEFAULT_HEADERS, null);
}
Unirest.java 文件源码 项目:unirest-android 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Set the asynchronous AbstractHttpAsyncClient implementation to use for every asynchronous request
 */
public static void setAsyncHttpClient(CloseableHttpAsyncClient asyncHttpClient) {
    Options.setOption(Option.ASYNCHTTPCLIENT, asyncHttpClient);
}
Unirest.java 文件源码 项目:unirest-android 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Close the asynchronous client and its event loop. Use this method to close all the threads and allow an application to exit.  
 */
public static void shutdown() throws IOException {
    CloseableHttpAsyncClient asyncClient = (CloseableHttpAsyncClient) Options.getOption(Option.ASYNCHTTPCLIENT);
    if (asyncClient.isRunning()) asyncClient.close();
}


问题


面经


文章

微信
公众号

扫码关注公众号