こんにちは私はサーバーがgzip圧縮をサポートしているかどうかを評価する必要があります。
したがって、リクエストでgzipをAccept-Encodingとして設定し、サーバーの応答に「Content-Encoding:gzip」が含まれているかどうかを評価します。
ただし、HTTPURLConnectionを使用してこれを行う方法についてはよくわかりません。特に、応答についてConnectionオブジェクトにクエリを実行する場合。私は現在:
HttpURLConnection con = (HttpURLConnection) feedurl.openConnection();
con.setRequestProperty("Accept-Encoding", "gzip");
System.out.println("Current Accept-Encoding: "+con.getRequestProperty("Accept-Encoding"));
//check the response for the content-size
float feedsize = con.getContentLength()/1024f;
//the server uses transfer-encoding=chunked and does not specify
//a content length
if(con.getContentLength()==-1)
{
//count the content size manually
CountingInputStream counter = new CountingInputStream(con.getInputStream());
while(counter.read()!=-1)
{}
feedsize=counter.getCount()/1024f;
}
con.disconnect();