Search in sources :

Example 1 with FlushedInputStream

use of com.nostra13.universalimageloader.core.assist.FlushedInputStream in project seadroid by haiwen.

the class AuthImageDownloader method getStreamFromNetwork.

@Override
protected InputStream getStreamFromNetwork(String imageUri, Object extra) throws IOException {
    HttpRequest req = HttpRequest.get(imageUri, null, false).readTimeout(readTimeout).connectTimeout(connectTimeout).followRedirects(true).header("Authorization", "Token " + ((Account) extra).token);
    HttpURLConnection conn = req.getConnection();
    if (conn instanceof HttpsURLConnection) {
        // Tell HttpRequest to trust all hosts, and then the user will get a dialog
        // where he needs to confirm the SSL certificate for the account,
        // and the accepted certificate will be stored, so he is not prompted to accept later on.
        // This is handled by SSLTrustManager and CertsManager
        req.trustAllHosts();
        HttpsURLConnection sconn = (HttpsURLConnection) conn;
        sconn.setSSLSocketFactory(SSLTrustManager.instance().getSSLSocketFactory((Account) extra));
    }
    return new FlushedInputStream(new BufferedInputStream(req.stream()));
}
Also used : HttpRequest(com.github.kevinsawicki.http.HttpRequest) Account(com.seafile.seadroid2.account.Account) FlushedInputStream(com.nostra13.universalimageloader.core.assist.FlushedInputStream) HttpURLConnection(java.net.HttpURLConnection) BufferedInputStream(java.io.BufferedInputStream) HttpsURLConnection(javax.net.ssl.HttpsURLConnection)

Aggregations

HttpRequest (com.github.kevinsawicki.http.HttpRequest)1 FlushedInputStream (com.nostra13.universalimageloader.core.assist.FlushedInputStream)1 Account (com.seafile.seadroid2.account.Account)1 BufferedInputStream (java.io.BufferedInputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 HttpsURLConnection (javax.net.ssl.HttpsURLConnection)1