GZIP在Android中 [英] GZIP in Android

查看:110
本文介绍了GZIP在Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想问有关发送GZIP在Android的使用HttpClient的POST请求?

i just wanted to ask about sending gzip for post requests using HttpClient in Android?

从哪里获取的OutputStream将在GZIPOutputstream通过呢?

where to get that OutputStream to be passed in the GZIPOutputstream?

任何片段?

推荐答案

喜UseHttpUriRequest如下图

Hi UseHttpUriRequest as shown below

 String urlval=" http"//www.sampleurl.com/";
    HttpUriRequest req = new HttpGet(urlval);
    req.addHeader("Accept-Encoding", "gzip");
    httpClient.execute(req);

,然后检查响应的内容编码,如下所示:

and then Check response for content encoding as shown below :

InputStream is = response.getEntity().getContent();
Header contentEncoding = response.getFirstHeader("Content-Encoding");
if (contentEncoding != null && contentEncoding.getValue().equalsIgnoreCase("gzip")) {
    is = new GZIPInputStream(is);
}

这篇关于GZIP在Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆