use of com.squareup.okhttp.OkUrlFactory in project markdown-doclet by Abnaxos.
the class GithubAccessor method createCachedHttpConnector.
private OkHttpConnector createCachedHttpConnector() {
final File cacheDirectory = getCacheDirectory();
final Cache cache = new Cache(cacheDirectory, this.cacheSize);
return new OkHttpConnector(new OkUrlFactory(new OkHttpClient().setCache(cache)));
}
use of com.squareup.okhttp.OkUrlFactory in project AndroidNetworkDemo by dodocat.
the class SelfSignSslOkHttpStack method createConnection.
@Override
protected HttpURLConnection createConnection(URL url) throws IOException {
if ("https".equals(url.getProtocol()) && socketFactoryMap.containsKey(url.getHost())) {
HttpsURLConnection connection = (HttpsURLConnection) new OkUrlFactory(okHttpClient).open(url);
connection.setSSLSocketFactory(socketFactoryMap.get(url.getHost()));
return connection;
} else {
return new OkUrlFactory(okHttpClient).open(url);
}
}
use of com.squareup.okhttp.OkUrlFactory in project robospice by stephanenicolas.
the class OkHttpBinaryRequest method loadDataFromNetwork.
@Override
public final InputStream loadDataFromNetwork() throws Exception {
try {
OkUrlFactory urlFactory = new OkUrlFactory(getOkHttpClient());
HttpURLConnection connection = urlFactory.open(new URL(url));
return processStream(connection.getContentLength(), connection.getInputStream());
} catch (final MalformedURLException e) {
Ln.e(e, "Unable to create URL");
throw e;
} catch (final IOException e) {
Ln.e(e, "Unable to download binary");
throw e;
}
}
use of com.squareup.okhttp.OkUrlFactory in project robospice by stephanenicolas.
the class OkHttpBitmapRequest method loadDataFromNetwork.
@Override
public Bitmap loadDataFromNetwork() throws Exception {
try {
OkUrlFactory urlFactory = new OkUrlFactory(getOkHttpClient());
HttpURLConnection connection = urlFactory.open(new URL(url));
processStream(connection.getContentLength(), connection.getInputStream());
if (width != -1 && height != -1) {
this.options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(cacheFile.getAbsolutePath(), options);
options.inSampleSize = calculateInSampleSize(options, width, height);
options.inJustDecodeBounds = false;
options.inPurgeable = true;
return BitmapFactory.decodeFile(cacheFile.getAbsolutePath(), options);
} else {
return BitmapFactory.decodeFile(cacheFile.getAbsolutePath(), options);
}
} catch (final MalformedURLException e) {
Ln.e(e, "Unable to create URL");
throw e;
} catch (final IOException e) {
Ln.e(e, "Unable to download binary");
throw e;
}
}
use of com.squareup.okhttp.OkUrlFactory in project robospice by stephanenicolas.
the class OkHttpSimpleTextRequest method loadDataFromNetwork.
// can't use activity here or any non serializable field
// will be invoked in remote service
@Override
public String loadDataFromNetwork() throws Exception {
try {
Ln.d("Call web service " + url);
OkUrlFactory urlFactory = new OkUrlFactory(getOkHttpClient());
HttpURLConnection connection = urlFactory.open(new URL(url));
return IOUtils.toString(connection.getInputStream());
} catch (final MalformedURLException e) {
Ln.e(e, "Unable to create URL");
throw e;
} catch (final IOException e) {
Ln.e(e, "Unable to download content");
throw e;
}
}
Aggregations