當前位置: 首頁>>代碼示例>>Java>>正文


Java AndroidHttpClient.getUngzippedContent方法代碼示例

本文整理匯總了Java中android.net.http.AndroidHttpClient.getUngzippedContent方法的典型用法代碼示例。如果您正苦於以下問題:Java AndroidHttpClient.getUngzippedContent方法的具體用法?Java AndroidHttpClient.getUngzippedContent怎麽用?Java AndroidHttpClient.getUngzippedContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.net.http.AndroidHttpClient的用法示例。


在下文中一共展示了AndroidHttpClient.getUngzippedContent方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getInputSteam

import android.net.http.AndroidHttpClient; //導入方法依賴的package包/類
public InputStream getInputSteam(HttpUriRequest request) throws IllegalStateException, IOException {
	request.setHeader(ACCEPT_KEY, ACCEPT_DEFAULT_VALUE);
	request.setHeader(USER_AGENT_KEY, sUserAgent);
	AndroidHttpClient.modifyRequestToAcceptGzipResponse(request);
	Log.xd(this, request);
       HttpClient client = mInputStreamHelper.getClient();
       HttpResponse response = client.execute(request);
	int statusCode = response.getStatusLine().getStatusCode();
       boolean isRedirect = isRedirect(statusCode);
       if (isRedirect) {
		Header firstHeader = response.getFirstHeader("Location");
		if (firstHeader != null) {
               String value = firstHeader.getValue();
               if (!StringUtil.isEmpty(value) && !value.equals(request.getURI().toString())) {
                   return createRedirectRequest(request, response, value);
               }
		}
	}
	if (mResponseStatusHandler != null) {
		mResponseStatusHandler.statusHandle(this, request, response);
	}
	HttpEntity httpEntity = response.getEntity();
       InputStream ungzippedContent = AndroidHttpClient.getUngzippedContent(httpEntity);
       return mInputStreamHelper.getInputStream(ungzippedContent, client);
}
 
開發者ID:IstiN,項目名稱:android_xcore,代碼行數:26,代碼來源:HttpAndroidDataSource.java

示例2: openHttpConnection

import android.net.http.AndroidHttpClient; //導入方法依賴的package包/類
/**
 * @param downloadUrl
 * @return
 * @throws IOException
 * @throws ClientProtocolException
 * @throws IllegalStateException
 */
private InputStream openHttpConnection(String downloadUrl)
		throws IOException, IllegalStateException {
	HttpGet get = new HttpGet(downloadUrl);

	AndroidHttpClient.modifyRequestToAcceptGzipResponse(get);
	HttpResponse response = httpClient.execute(get);

	InputStream is;
	HttpEntity entity = response.getEntity();
	is = AndroidHttpClient.getUngzippedContent(entity);
	return is;
}
 
開發者ID:kultus,項目名稱:StockAnalyze,代碼行數:20,代碼來源:DownloadService.java

示例3: getIfCompressed

import android.net.http.AndroidHttpClient; //導入方法依賴的package包/類
/**
 * Extracts the response content. If the server response is compressed, then
 * it transparently decompresses the content. In order to indicate to server
 * that you can consume JSON response, use the following code to add the "Accept"
 * header:
 *
 * AndroidHttpClient.modifyRequestToAcceptGzipResponse(HttpRequest request)
 * 
 * @param response
 *                   HttpResponse Object
 * @return String content of the HttpResponse
 */
public static String getIfCompressed(final HttpResponse response) {
    if (response == null)
        return null;

    try {
        final InputStream is = AndroidHttpClient.getUngzippedContent(response.getEntity());
        return streamToString(is);
    } catch (final IOException e) {
        e.printStackTrace();
    }

    return null;
}
 
開發者ID:hrj,項目名稱:trackMe,代碼行數:26,代碼來源:GzipHelper.java

示例4: getIfCompressed

import android.net.http.AndroidHttpClient; //導入方法依賴的package包/類
/**
 * Extracts the response content. If the server response is compressed, then
 * it transparently decompresses the content. In order to indicate to server
 * that you can consume JSON response, use the following code to add the "Accept"
 * header:
 *
 * AndroidHttpClient.modifyRequestToAcceptGzipResponse(HttpRequest request)
 * 
 * @param response
 *                   HttpResponse Object
 * @return String content of the HttpResponse
 */
public static String getIfCompressed(HttpResponse response) {
    if (response == null)
        return null;

    try {
        InputStream is = AndroidHttpClient.getUngzippedContent(response.getEntity());
        return streamToString(is);
    } catch (IOException e) {
        e.printStackTrace();
    }

    return null;
}
 
開發者ID:hrj,項目名稱:trackMe,代碼行數:26,代碼來源:GzipHelper.java

示例5: getUngzippedContent

import android.net.http.AndroidHttpClient; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.FROYO)
private static InputStream getUngzippedContent(HttpEntity entity)
		throws IOException {
	return AndroidHttpClient.getUngzippedContent(entity);
}
 
開發者ID:vuze,項目名稱:vuze-remote-for-android,代碼行數:6,代碼來源:RestJsonClientDeprecated.java


注:本文中的android.net.http.AndroidHttpClient.getUngzippedContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。