当前位置: 首页>>代码示例>>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;未经允许,请勿转载。