Codota Logo
OkUrlFactory
Code IndexAdd Codota to your IDE (free)

How to use
OkUrlFactory
in
okhttp3

Best Java code snippets using okhttp3.OkUrlFactory (Showing top 20 results out of 315)

  • Common ways to obtain OkUrlFactory
private void myMethod () {
OkUrlFactory o =
  • Codota IconOkHttpClient client;new OkUrlFactory(client)
  • Smart code suggestions by Codota
}
origin: square/okhttp

/**
 * Returns a copy of this stream handler factory that includes a shallow copy of the internal
 * {@linkplain OkHttpClient HTTP client}.
 */
@Override public OkUrlFactory clone() {
 return new OkUrlFactory(client);
}
origin: square/okhttp

@Override protected URLConnection openConnection(URL url, Proxy proxy) {
 return open(url, proxy);
}
origin: square/okhttp

 /** Sets the response cache to be used to read and write cached responses. */
 public static void setResponseCache(OkUrlFactory okUrlFactory, ResponseCache responseCache) {
  OkHttpClient.Builder builder = okUrlFactory.client().newBuilder();
  if (responseCache instanceof OkCacheContainer) {
   // Avoid adding layers of wrappers. Rather than wrap the ResponseCache in yet another layer to
   // make the ResponseCache look like an InternalCache, we can unwrap the Cache instead.
   // This means that Cache stats will be correctly updated.
   OkCacheContainer okCacheContainer = (OkCacheContainer) responseCache;
   builder.cache(okCacheContainer.getCache());
  } else {
   builder.setInternalCache(responseCache != null ? new CacheAdapter(responseCache) : null);
  }
  okUrlFactory.setClient(builder.build());
 }
}
origin: cloudant/java-cloudant

@Override
public HttpURLConnection openConnection(URL url) throws IOException {
  if (factory == null) {
    factory = new OkUrlFactory(clientBuilder.build());
  }
  return factory.open(url);
}
origin: cloudant/java-cloudant

  @Override
  public void shutdown() {
    try {
      factory.client().dispatcher().executorService().shutdown();
      factory.client().dispatcher().executorService().awaitTermination(5, TimeUnit.MINUTES);
      // Evict all the connections
      factory.client().connectionPool().evictAll();
    } catch (InterruptedException e) {
      // Oh well; we were only trying to aggressively shutdown
    }
  }
}
origin: tinyMediaManager/tinyMediaManager

HttpURLConnection connection = new OkUrlFactory(TmmHttpClient.getHttpClient()).open(new URL(request));
connection.setDoOutput(true);
connection.setDoInput(true);
origin: square/okhttp

@Override protected URLConnection openConnection(URL url) {
 return open(url);
}
origin: org.tinymediamanager.plugins/scraper-opensubtitles

Call c = new Call(methodName, params);
HttpURLConnection http = new OkUrlFactory(client).open(url);
http.setRequestProperty(USER_AGENT, userAgent);
http.setRequestMethod(HTTP_POST);
origin: com.squareup.okhttp3/okhttp-urlconnection

/**
 * Returns a copy of this stream handler factory that includes a shallow copy of the internal
 * {@linkplain OkHttpClient HTTP client}.
 */
@Override public OkUrlFactory clone() {
 return new OkUrlFactory(client);
}
origin: com.squareup.okhttp3/okhttp-android-support

 /** Sets the response cache to be used to read and write cached responses. */
 public static void setResponseCache(OkUrlFactory okUrlFactory, ResponseCache responseCache) {
  OkHttpClient.Builder builder = okUrlFactory.client().newBuilder();
  if (responseCache instanceof OkCacheContainer) {
   // Avoid adding layers of wrappers. Rather than wrap the ResponseCache in yet another layer to
   // make the ResponseCache look like an InternalCache, we can unwrap the Cache instead.
   // This means that Cache stats will be correctly updated.
   OkCacheContainer okCacheContainer = (OkCacheContainer) responseCache;
   builder.cache(okCacheContainer.getCache());
  } else {
   builder.setInternalCache(responseCache != null ? new CacheAdapter(responseCache) : null);
  }
  okUrlFactory.setClient(builder.build());
 }
}
origin: square/okhttp

public HttpURLConnection open(URL url) {
 return open(url, client.proxy());
}
origin: com.github.ljun20160606/okhttp-urlconnection

/**
 * Returns a copy of this stream handler factory that includes a shallow copy of the internal
 * {@linkplain OkHttpClient HTTP client}.
 */
@Override public OkUrlFactory clone() {
 return new OkUrlFactory(client);
}
origin: kohsuke/github-api

  public HttpURLConnection connect(URL url) throws IOException {
    return urlFactory.open(url);
  }
}
origin: apache/servicemix-bundles

/**
 * Returns a copy of this stream handler factory that includes a shallow copy of the internal
 * {@linkplain OkHttpClient HTTP client}.
 */
@Override public OkUrlFactory clone() {
 return new OkUrlFactory(client);
}
origin: org.kohsuke/github-api

  public HttpURLConnection connect(URL url) throws IOException {
    return urlFactory.open(url);
  }
}
origin: fullcontact/fullcontact4j

public FCUrlClient(String userAgent, Map<String, String> customHeaders, OkHttpClient client, String apiKey) {
  okUrlFactory = new OkUrlFactory(client);
  if(customHeaders != null) {
    this.headers = customHeaders;
  }
  //disallow api key, token, or user agent headers to be supplied by the user
  boolean removedBlocked = headers.remove(FCConstants.HEADER_AUTH_API_KEY) != null;
  removedBlocked |= headers.remove(FCConstants.HEADER_AUTH_ACCESS_TOKEN) != null;
  if(removedBlocked) {
    Utils.info("Custom FullContact header for api key or access token was supplied. It has been ignored.");
  }
  this.userAgent = userAgent;
  this.apiKey = apiKey;
}
origin: com.github.ljun20160606/okhttp-urlconnection

@Override protected URLConnection openConnection(URL url) {
 return open(url);
}
origin: jenkins-infra/update-center2

private void retrieveRepositoryNames() throws IOException {
  System.err.println("Retrieving GitHub repository names...");
  Cache cache = new Cache(GITHUB_API_CACHE, 20L*1024*1024); // 20 MB cache
  github = new GitHubBuilder().withConnector(new OkHttp3Connector(new OkUrlFactory(new OkHttpClient.Builder().cache(cache).build()))).withPassword(GITHUB_API_USERNAME, GITHUB_API_PASSWORD).build();
  List<String> ret = new ArrayList<>();
  for (GHRepository repo : github.getOrganization("jenkinsci").listRepositories().withPageSize(100)) {
    ret.add(repo.getHtmlUrl().toString());
  }
  Files.write(GITHUB_REPO_LIST.toPath(), ret);
}
origin: apache/servicemix-bundles

@Override protected URLConnection openConnection(URL url, Proxy proxy) {
 return open(url, proxy);
}
origin: com.squareup.okhttp3/okhttp-urlconnection

@Override protected URLConnection openConnection(URL url, Proxy proxy) {
 return open(url, proxy);
}
okhttp3OkUrlFactory

Most used methods

  • <init>
  • open
  • client
  • setClient

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSystemService (Context)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • setScale (BigDecimal)
    Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to thi
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • Path (java.nio.file)
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now