本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}