Java 类com.bumptech.glide.util.ContentLengthInputStream 实例源码

项目:MVVMFrames    文件:OkHttpStreamFetcher.java   
@Override
public InputStream loadData(Priority priority) throws Exception {
    Request.Builder requestBuilder = new Request.Builder().url(url.toStringUrl());

    for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
        String key = headerEntry.getKey();
        requestBuilder.addHeader(key, headerEntry.getValue());
    }
    Request request = requestBuilder.build();

    Response response;
    call = client.newCall(request);
    response = call.execute();
    responseBody = response.body();
    if (!response.isSuccessful()) {
        throw new IOException("Request failed with code: " + response.code());
    }

    long contentLength = responseBody.contentLength();
    stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
    return stream;
}
项目:PeSanKita-android    文件:OkHttpStreamFetcher.java   
@Override
public InputStream loadData(Priority priority) throws Exception {
  Request.Builder requestBuilder = new Request.Builder()
      .url(url.toStringUrl());

  for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
    String key = headerEntry.getKey();
    requestBuilder.addHeader(key, headerEntry.getValue());
  }

  Request  request  = requestBuilder.build();
  Response response = client.newCall(request).execute();

  responseBody = response.body();

  if (!response.isSuccessful()) {
    throw new IOException("Request failed with code: " + response.code());
  }

  long contentLength = responseBody.contentLength();
  stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
  return stream;
}
项目:TestChat    文件:OkHttpStreamFetcher.java   
@Override
public InputStream loadData(Priority priority) throws Exception {
    Request.Builder requestBuilder = new Request.Builder()
            .url(url.toStringUrl());

    for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
        String key = headerEntry.getKey();
        requestBuilder.addHeader(key, headerEntry.getValue());
    }

    Request request = requestBuilder.build();

    Response response = client.newCall(request).execute();
    responseBody = response.body();
    if (!response.isSuccessful()) {
        throw new IOException("Request failed with code: " + response.code());
    }

    long contentLength = responseBody.contentLength();
    stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
    return stream;
}
项目:Hotspot-master-devp    文件:OkHttpStreamFetcher.java   
@Override
public InputStream loadData(Priority priority) throws Exception {
    Request.Builder requestBuilder = new Request.Builder()
            .url(url.toStringUrl());

    for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
        String key = headerEntry.getKey();
        requestBuilder.addHeader(key, headerEntry.getValue());
    }

    Request request = requestBuilder.build();

    Response response = client.newCall(request).execute();
    responseBody = response.body();
    if (!response.isSuccessful()) {
        throw new IOException("Request failed with code: " + response.code());
    }

    long contentLength = responseBody.contentLength();
    stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
    return stream;
}
项目:MVPArms_Fragment-fragment    文件:OkHttpStreamFetcher.java   
@Override
public InputStream loadData(Priority priority) throws Exception {
    Request.Builder requestBuilder = new Request.Builder().url(url.toStringUrl());

    for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
        String key = headerEntry.getKey();
        requestBuilder.addHeader(key, headerEntry.getValue());
    }
    Request request = requestBuilder.build();

    Response response;
    call = client.newCall(request);
    response = call.execute();
    responseBody = response.body();
    if (!response.isSuccessful()) {
        throw new IOException("Request failed with code: " + response.code());
    }

    long contentLength = responseBody.contentLength();
    stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
    return stream;
}
项目:ITSM    文件:OkHttpStreamFetcher.java   
@Override
public InputStream loadData(Priority priority) throws Exception {
    Request.Builder requestBuilder = new Request.Builder().url(url.toStringUrl());

    for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
        String key = headerEntry.getKey();
        requestBuilder.addHeader(key, headerEntry.getValue());
    }
    Request request = requestBuilder.build();

    Response response;
    call = client.newCall(request);
    response = call.execute();
    responseBody = response.body();
    if (!response.isSuccessful()) {
        throw new IOException("Request failed with code: " + response.code());
    }

    long contentLength = responseBody.contentLength();
    stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
    return stream;
}
项目:Cable-Android    文件:OkHttpStreamFetcher.java   
@Override
public InputStream loadData(Priority priority) throws Exception {
  Request.Builder requestBuilder = new Request.Builder()
      .url(url.toStringUrl());

  for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
    String key = headerEntry.getKey();
    requestBuilder.addHeader(key, headerEntry.getValue());
  }

  Request  request  = requestBuilder.build();
  Response response = client.newCall(request).execute();

  responseBody = response.body();

  if (!response.isSuccessful()) {
    throw new IOException("Request failed with code: " + response.code());
  }

  long contentLength = responseBody.contentLength();
  stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
  return stream;
}
项目:MVPArmsTest1    文件:OkHttpStreamFetcher.java   
@Override
public InputStream loadData(Priority priority) throws Exception {
    Request.Builder requestBuilder = new Request.Builder().url(url.toStringUrl());

    for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
        String key = headerEntry.getKey();
        requestBuilder.addHeader(key, headerEntry.getValue());
    }
    Request request = requestBuilder.build();

    Response response;
    call = client.newCall(request);
    response = call.execute();
    responseBody = response.body();
    if (!response.isSuccessful()) {
        throw new IOException("Request failed with code: " + response.code());
    }

    long contentLength = responseBody.contentLength();
    stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
    return stream;
}
项目:AndroidModulePattern    文件:OkHttpStreamFetcher.java   
@Override
public InputStream loadData(Priority priority) throws Exception {
    Request.Builder requestBuilder = new Request.Builder()
            .url(url.toStringUrl());

    for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
        String key = headerEntry.getKey();
        requestBuilder.addHeader(key, headerEntry.getValue());
    }

    Request request = requestBuilder.build();

    Response response = client.newCall(request).execute();
    responseBody = response.body();
    if (!response.isSuccessful()) {
        throw new IOException("Request failed with code: " + response.code());
    }

    long contentLength = responseBody.contentLength();
    stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
    return stream;
}
项目:glide-support    文件:StethoHttpUrlFetcher.java   
private InputStream getStreamForSuccessfulRequest(HttpURLConnection urlConnection) throws IOException {
    try {
        InputStream responseStream = stethoManager.interpretResponseStream(urlConnection.getInputStream());
        if (TextUtils.isEmpty(urlConnection.getContentEncoding())) {
            int contentLength = urlConnection.getContentLength();
            stream = ContentLengthInputStream.obtain(responseStream, contentLength);
        } else {
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, "Got non empty content encoding: " + urlConnection.getContentEncoding());
            }
            stream = responseStream;
        }
        return stream;
    } catch (IOException ex) {
        stethoManager.httpExchangeFailed(ex);
        throw ex;
    }
}
项目:AndroidBase    文件:OkHttpStreamFetcher.java   
@Override
public InputStream loadData(Priority priority) throws Exception {
  Request.Builder requestBuilder = new Request.Builder().url(url.toStringUrl());

  for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
    String key = headerEntry.getKey();
    requestBuilder.addHeader(key, headerEntry.getValue());
  }
  Request request = requestBuilder.build();

  Response response;
  call = client.newCall(request);
  response = call.execute();
  responseBody = response.body();
  if (!response.isSuccessful()) {
    throw new IOException("Request failed with code: " + response.code());
  }

  long contentLength = responseBody.contentLength();
  stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
  return stream;
}
项目:QingNianTuZhai    文件:OkHttpStreamFetcher.java   
@Override
public InputStream loadData(Priority priority) throws Exception {
    Request.Builder requestBuilder = new Request.Builder().url(url.toStringUrl());

    for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
        String key = headerEntry.getKey();
        requestBuilder.addHeader(key, headerEntry.getValue());
    }
    Request request = requestBuilder.build();

    Response response;
    call = client.newCall(request);
    response = call.execute();
    responseBody = response.body();
    if (!response.isSuccessful()) {
        throw new IOException("Request failed with code: " + response.code());
    }

    long contentLength = responseBody.contentLength();
    stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
    return stream;
}
项目:android-tutorials-glide    文件:OkHttpStreamFetcher.java   
@Override
public InputStream loadData(Priority priority) throws Exception {
    Request.Builder requestBuilder = new Request.Builder()
            .url(url.toStringUrl());

    for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
        String key = headerEntry.getKey();
        requestBuilder.addHeader(key, headerEntry.getValue());
    }

    Request request = requestBuilder.build();

    Response response = client.newCall(request).execute();
    responseBody = response.body();
    if (!response.isSuccessful()) {
        throw new IOException("Request failed with code: " + response.code());
    }

    long contentLength = responseBody.contentLength();
    stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
    return stream;
}
项目:GitHub    文件:HttpUrlFetcher.java   
private InputStream getStreamForSuccessfulRequest(HttpURLConnection urlConnection)
    throws IOException {
  if (TextUtils.isEmpty(urlConnection.getContentEncoding())) {
    int contentLength = urlConnection.getContentLength();
    stream = ContentLengthInputStream.obtain(urlConnection.getInputStream(), contentLength);
  } else {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
      Log.d(TAG, "Got non empty content encoding: " + urlConnection.getContentEncoding());
    }
    stream = urlConnection.getInputStream();
  }
  return stream;
}
项目:GitHub    文件:OkHttpStreamFetcher.java   
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
  responseBody = response.body();
  if (response.isSuccessful()) {
    long contentLength = Preconditions.checkNotNull(responseBody).contentLength();
    stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
    callback.onDataReady(stream);
  } else {
    callback.onLoadFailed(new HttpException(response.message(), response.code()));
  }
}
项目:GitHub    文件:HttpUrlFetcher.java   
private InputStream getStreamForSuccessfulRequest(HttpURLConnection urlConnection)
    throws IOException {
  if (TextUtils.isEmpty(urlConnection.getContentEncoding())) {
    int contentLength = urlConnection.getContentLength();
    stream = ContentLengthInputStream.obtain(urlConnection.getInputStream(), contentLength);
  } else {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
      Log.d(TAG, "Got non empty content encoding: " + urlConnection.getContentEncoding());
    }
    stream = urlConnection.getInputStream();
  }
  return stream;
}
项目:MoligyMvpArms    文件:OkHttpStreamFetcher.java   
@Override
public void onResponse(Call call, Response response) throws IOException {
    responseBody = response.body();
    if (response.isSuccessful()) {
        long contentLength = responseBody.contentLength();
        stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
        callback.onDataReady(stream);
    } else {
        callback.onLoadFailed(new HttpException(response.message(), response.code()));
    }
}
项目:FastAndroid    文件:OkHttpStreamFetcher.java   
@Override
public void onResponse(Call call, Response response) throws IOException {
    responseBody = response.body();
    if (response.isSuccessful()) {
        long contentLength = responseBody.contentLength();
        stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
        callback.onDataReady(stream);
    } else {
        callback.onLoadFailed(new HttpException(response.message(), response.code()));
    }
}
项目:Aurora    文件:OkHttpStreamFetcher.java   
@Override
public void onResponse(Call call, Response response) throws IOException {
    responseBody = response.body();
    if (response.isSuccessful()) {
        long contentLength = responseBody.contentLength();
        stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
        callback.onDataReady(stream);
    } else {
        callback.onLoadFailed(new HttpException(response.message(), response.code()));
    }
}
项目:MVVMArms    文件:OkHttpStreamFetcher.java   
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
    responseBody = response.body();
    if (response.isSuccessful()) {
        long contentLength = responseBody.contentLength();
        stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
        callback.onDataReady(stream);
    } else {
        callback.onLoadFailed(new HttpException(response.message(), response.code()));
    }
}
项目:MVPArms    文件:OkHttpStreamFetcher.java   
@Override
public void onResponse(Call call, Response response) throws IOException {
    responseBody = response.body();
    if (response.isSuccessful()) {
        long contentLength = responseBody.contentLength();
        stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
        callback.onDataReady(stream);
    } else {
        callback.onLoadFailed(new HttpException(response.message(), response.code()));
    }
}
项目:hipda    文件:ImageStreamFetcher.java   
@Override
public InputStream loadData(Priority priority) throws Exception {
    Request request = getRequest();

    Response response = client.newCall(request).execute();
    responseBody = response.body();
    if (!response.isSuccessful()) {
        throw new IOException(OkHttpHelper.ERROR_CODE_PREFIX + response.code());
    }

    long contentLength = responseBody.contentLength();
    stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
    return stream;
}