String result = shortUrl;
String header;
do {
URL url = new URL(result);
HttpURLConnection.setFollowRedirects( false );
URLConnection conn = url.openConnection();
header = conn.getHeaderField( null );
Log.e( "msg" , "header : " + header);
String location = conn.getHeaderField( "Location" );
Log.e( "msg" , "location : " + location);
if (location != null ) {
result = location;
}
} while (header.contains( "301" ));
|
위의 소스는 (물론 log.e 제외) 자바에서 단축url로 long url 값을 알아오는 것인데요.
이 것을 안드로이드에 그대로 넣고 실행 시키면 header = conn.getHeaderField(null); 부분에서 에러가 발생합니다.
이 외에 방법으로 header 값을 알 수 있는 방법이 있을까요?