OSDN Git Service

HttpComponent4.1でdeprecatedになったメソッドの置き換え
authoryukihane <yukihane.feather@gmail.com>
Mon, 15 Aug 2011 03:05:52 +0000 (12:05 +0900)
committeryukihane <yukihane.feather@gmail.com>
Mon, 15 Aug 2011 03:05:52 +0000 (12:05 +0900)
src/nicobrowser/NicoHttpClient.java

index 38afcbc..3ed4017 100644 (file)
@@ -69,6 +69,7 @@ import org.apache.http.impl.client.RedirectLocations;
 import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.EntityUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -137,7 +138,7 @@ public class NicoHttpClient {
 
             // ログイン可否の判定.
             HttpEntity entity = response.getEntity();
-            entity.consumeContent();
+            EntityUtils.consume(entity);
             List<Cookie> cookies = http.getCookieStore().getCookies();
             if (!cookies.isEmpty()) {
                 auth = true;
@@ -162,7 +163,7 @@ public class NicoHttpClient {
             if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                 result = true;
             }
-            response.getEntity().consumeContent();
+            EntityUtils.consume(response.getEntity());
         } catch (IOException ex) {
             logger.error("ログアウト時に問題が発生", ex);
         }
@@ -235,7 +236,7 @@ public class NicoHttpClient {
             // reader.skip(1);
             list = getNicoContents(reader);
             deleteRankString(list);
-            response.getEntity().consumeContent();
+            EntityUtils.consume(response.getEntity());
         } catch (FeedException ex) {
             logger.error("", ex);
         } catch (IOException ex) {
@@ -287,7 +288,7 @@ public class NicoHttpClient {
             res = br.readLine();
             logger.debug("wayback get result text: " + res);
         } finally {
-            response.getEntity().consumeContent();
+            EntityUtils.consume(response.getEntity());
         }
 
         final String keyWayBackKey = "waybackkey=";
@@ -586,7 +587,7 @@ public class NicoHttpClient {
                 strBuilder.append(str);
             }
             resultString = strBuilder.toString();
-            response.getEntity().consumeContent();
+            EntityUtils.consume(response.getEntity());
             logger.debug(resultString);
         } finally {
             if (reader != null) {
@@ -666,7 +667,7 @@ public class NicoHttpClient {
 
             title = getTitleInWatchPage(response.getEntity().getContent());
         } finally {
-            response.getEntity().consumeContent();
+            EntityUtils.consume(response.getEntity());
         }
         return new GetRealVideoIdResult(realId, title);
     }
@@ -691,7 +692,7 @@ public class NicoHttpClient {
             HttpGet get = new HttpGet(notifierUrl.toString());
             HttpResponse response = http.execute(get);
             userName = Util.getUserName(response.getEntity().getContent());
-            response.getEntity().consumeContent();
+            EntityUtils.consume(response.getEntity());
         }
 
         final URL url = vi.getVideoUrl();
@@ -712,7 +713,7 @@ public class NicoHttpClient {
         logger.debug(downloadFile.toString());
         if ("text/plain".equals(contentType) || "text/html".equals(contentType)) {
             logger.error("取得できませんでした. サーバが混みあっている可能性があります: " + vi.getRealVideoId());
-            response.getEntity().consumeContent();
+            EntityUtils.consume(response.getEntity());
             return new GetFlvResult(null, Status.GET_INFO, userName);
         }
         String ext = Util.getExtention(contentType);
@@ -738,7 +739,7 @@ public class NicoHttpClient {
             }
         }
 
-        response.getEntity().consumeContent();
+        EntityUtils.consume(response.getEntity());
         out.close();
         in.close();
         if (url.toString().contains("low")) {
@@ -834,7 +835,7 @@ public class NicoHttpClient {
             throw new Exception("コメントダウンロードに失敗しました。", e);
         } finally {
             if (response != null) {
-                response.getEntity().consumeContent();
+                EntityUtils.consume(response.getEntity());
             }
             if (bos != null) {
                 bos.close();
@@ -956,7 +957,7 @@ public class NicoHttpClient {
                 }
             }
         } finally {
-            entity.consumeContent();
+            EntityUtils.consume(entity);
         }
 
         if (itemType == null || itemId == null || token == null) {
@@ -977,7 +978,7 @@ public class NicoHttpClient {
         post.setEntity(se);
         response = http.execute(post);
         int statusCode = response.getStatusLine().getStatusCode();
-        response.getEntity().consumeContent();
+        EntityUtils.consume(response.getEntity());
         if (statusCode != HttpStatus.SC_OK) {
             throw new IOException("マイリスト登録に失敗" + "マイリスト:" + myListId + ", 動画ID:" + videoId);
         }