本文整理匯總了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);
}