hide HttpClient interface
authorEugene Petrenko <eugene.petrenko@gmail.com>
Fri, 12 Aug 2011 11:18:18 +0000 (15:18 +0400)
committerEugene Petrenko <eugene.petrenko@gmail.com>
Fri, 12 Aug 2011 11:18:18 +0000 (15:18 +0400)
nuget-server/src/jetbrains/buildServer/nuget/server/feed/reader/impl/FeedClient.java
nuget-server/src/jetbrains/buildServer/nuget/server/feed/reader/impl/FeedHttpClientHolder.java
nuget-server/src/jetbrains/buildServer/nuget/server/feed/reader/impl/NuGetFeedReaderImpl.java
nuget-server/src/jetbrains/buildServer/nuget/server/feed/reader/impl/UrlResolverImpl.java

index 629e37426b7a3d0761691c17a87ddf2c6ecfa967..22a904b9703ced77391426f9f46554a6f3b8df2b 100644 (file)
 \r
 package jetbrains.buildServer.nuget.server.feed.reader.impl;\r
 \r
+import org.apache.http.HttpResponse;\r
 import org.apache.http.client.HttpClient;\r
+import org.apache.http.client.methods.HttpUriRequest;\r
 import org.jetbrains.annotations.NotNull;\r
 \r
+import java.io.IOException;\r
+\r
 /**\r
  * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
  * Date: 12.08.11 15:13\r
  */\r
 public interface FeedClient {\r
   @NotNull\r
-  HttpClient getClient();\r
+  HttpResponse execute(@NotNull HttpUriRequest request) throws IOException;\r
 }\r
index 1c1df126af6ebcb82ec5512d47dd94aef23e391f..0a7caf289940a28c2a5051021c86fbd2effec103 100644 (file)
@@ -17,7 +17,9 @@
 package jetbrains.buildServer.nuget.server.feed.reader.impl;\r
 \r
 import jetbrains.buildServer.version.ServerVersionHolder;\r
+import org.apache.http.HttpResponse;\r
 import org.apache.http.client.HttpClient;\r
+import org.apache.http.client.methods.HttpUriRequest;\r
 import org.apache.http.impl.client.DefaultHttpClient;\r
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;\r
 import org.apache.http.params.HttpConnectionParams;\r
@@ -25,6 +27,8 @@ import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;\r
 import org.jetbrains.annotations.NotNull;\r
 \r
+import java.io.IOException;\r
+\r
 /**\r
  * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
  * Date: 11.08.11 16:24\r
@@ -48,6 +52,11 @@ public class FeedHttpClientHolder implements FeedClient {
     return myClient;\r
   }\r
 \r
+  @NotNull\r
+  public HttpResponse execute(@NotNull HttpUriRequest request) throws IOException {\r
+    return myClient.execute(request);\r
+  }\r
+\r
   public void dispose() {\r
     myClient.getConnectionManager().shutdown();\r
   }\r
index 56802e037272370675cbbba4f67b1efe73d544cb..55e795c65b8b6ec79938ab74ef0fe1bdb537570d 100644 (file)
@@ -71,7 +71,7 @@ public class NuGetFeedReaderImpl implements NuGetFeedReader {
 \r
     LOG.debug("Query for packages: " + get.getURI());\r
 \r
-    final HttpResponse execute = myClient.getClient().execute(get);\r
+    final HttpResponse execute = myClient.execute(get);\r
     return myParser.readPackages(toDocument(execute));\r
   }\r
 \r
@@ -80,7 +80,7 @@ public class NuGetFeedReaderImpl implements NuGetFeedReader {
     final String url = pkg.getDownloadUrl();\r
 \r
     final HttpGet get = myMethodFactory.createGet(url);\r
-    final HttpResponse resp = myClient.getClient().execute(get);\r
+    final HttpResponse resp = myClient.execute(get);\r
     final StatusLine statusLine = resp.getStatusLine();\r
     if (statusLine.getStatusCode() != HttpStatus.SC_OK) {\r
       throw new IOException("Failed to download package " + pkg + ". Server returned " + statusLine);\r
index 00fed706201a3b56b14fdd423ee5cb413d3d60fa..4a583ab6191c9aa6a3dd6e2d07f83b47300ac341 100644 (file)
@@ -55,7 +55,7 @@ public class UrlResolverImpl implements UrlResolver {
       HttpGet ping = myMethods.createGet(feedUrl);\r
       ping.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);\r
 \r
-      final HttpResponse execute = myClient.getClient().execute(ping);\r
+      final HttpResponse execute = myClient.execute(ping);\r
       final int statusCode = execute.getStatusLine().getStatusCode();\r
       if (statusCode / 100 == 3) {\r
         final Header location = execute.getFirstHeader("Location");\r