Android HttpClinet で、HTTP-Head とコンテンツを取得
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
:
:
AndroidHttpClient client = AndroidHttpClient.newInstance("Android");
HttpResponse response = client.execute(new HttpGet(url));
String responseText = null;
HttpResponse response =client.execute(new HttpGet(url));
Header[] headers = response.getAllHeaders();
for(Header h : headers){
Log.d("sample","header name=["+h.getName()+"] value=["+h.getValue()+"]");
}
String body;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
response.getEntity().writeTo(stream);
if (response.getStatusLine().getStatusCode()==HttpStatus.SC_OK){
body = stream.toByteArray();
}
stream.close();