Author: maartenc
Date: Fri Aug  8 14:59:36 2008
New Revision: 684120

URL: http://svn.apache.org/viewvc?rev=684120&view=rev
Log:
NEW: Report version of Ivy in HTTP headers (user-agent?) when Ivy downloads 
artifacts (IVY-878)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=684120&r1=684119&r2=684120&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Fri Aug  8 14:59:36 2008
@@ -76,6 +76,7 @@
 
    trunk version
 =====================================
+- NEW: Report version of Ivy in HTTP headers (user-agent?) when Ivy downloads 
artifacts (IVY-878)
 - NEW: Add publish support to URL resolver (IVY-848) (thanks to Brian Sanders)
 - NEW: Better support for local builds (IVY-857)
 - NEW: Retain original dependency constraint rules in resolved ivy file 
(IVY-739)

Modified: 
ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java?rev=684120&r1=684119&r2=684120&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java 
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java 
Fri Aug  8 14:59:36 2008
@@ -23,6 +23,7 @@
 import java.net.URLConnection;
 import java.net.UnknownHostException;
 
+import org.apache.ivy.Ivy;
 import org.apache.ivy.util.CopyProgressListener;
 import org.apache.ivy.util.FileUtil;
 import org.apache.ivy.util.Message;
@@ -58,6 +59,7 @@
         URLConnection con = null;
         try {
             con = url.openConnection();
+            con.setRequestProperty("User-Agent", "Apache Ivy/" + 
Ivy.getIvyVersion());
             if (con instanceof HttpURLConnection) {
                 ((HttpURLConnection) con).setRequestMethod("HEAD");
                 int status = ((HttpURLConnection) con).getResponseCode();
@@ -100,6 +102,7 @@
         InputStream inStream = null;
         try {
             conn = url.openConnection();
+            conn.setRequestProperty("User-Agent", "Apache Ivy/" + 
Ivy.getIvyVersion());
             inStream = conn.getInputStream();
             ByteArrayOutputStream outStream = new ByteArrayOutputStream();
 
@@ -122,6 +125,7 @@
         URLConnection srcConn = null;
         try {
             srcConn = src.openConnection();
+            srcConn.setRequestProperty("User-Agent", "Apache Ivy/" + 
Ivy.getIvyVersion());
             int contentLength = srcConn.getContentLength();
             FileUtil.copy(srcConn.getInputStream(), dest, l);
             if (dest.length() != contentLength && contentLength != -1) {
@@ -150,7 +154,7 @@
             conn = (HttpURLConnection) dest.openConnection();
             conn.setDoOutput(true);
             conn.setRequestMethod("PUT");
-            conn.setRequestProperty("User-Agent", "Apache Ivy");
+            conn.setRequestProperty("User-Agent", "Apache Ivy/" + 
Ivy.getIvyVersion());
             conn.setRequestProperty("Content-type", 
"application/octet-stream");
             conn.setRequestProperty("Content-length", 
Long.toString(source.length()));
             conn.setInstanceFollowRedirects(true);

Modified: 
ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java?rev=684120&r1=684119&r2=684120&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java 
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java 
Fri Aug  8 14:59:36 2008
@@ -41,6 +41,8 @@
 import org.apache.commons.httpclient.methods.HeadMethod;
 import org.apache.commons.httpclient.methods.PutMethod;
 import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
+import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.apache.ivy.Ivy;
 import org.apache.ivy.util.CopyProgressListener;
 import org.apache.ivy.util.Credentials;
 import org.apache.ivy.util.FileUtil;
@@ -256,6 +258,9 @@
                         new UsernamePasswordCredentials(proxyUserName, 
proxyPasswd));
                 }
             }
+            
+            // user-agent
+            httpClient.getParams().setParameter("http.useragent", "Apache 
Ivy/" + Ivy.getIvyVersion());
         }
         
         Credentials c = getCredentials(url);


Reply via email to