You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2009/02/14 17:46:33 UTC

svn commit: r744520 - in /httpcomponents/httpclient/trunk: ./ module-client/src/main/java/org/apache/http/conn/scheme/ module-client/src/test/java/org/apache/http/conn/scheme/

Author: olegk
Date: Sat Feb 14 16:46:33 2009
New Revision: 744520

URL: http://svn.apache.org/viewvc?rev=744520&view=rev
Log:
HTTPCLIENT-813: Fixed default port resolution. Invalid ports no longer get replaced with the default port value.

Added:
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/scheme/
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/scheme/TestScheme.java
Modified:
    httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/Scheme.java

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=744520&r1=744519&r2=744520&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Sat Feb 14 16:46:33 2009
@@ -9,6 +9,10 @@
 
 All upstream projects are strongly encouraged to upgrade.
 
+* [HTTPCLIENT-813] Fixed default port resolution. Invalid ports no longer
+  get replaced with the default port value.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * Fixed NPE in DefaultRequestDirector thrown when retrying a failed 
   request over a proxied connection. 
   Contributed by Oleg Kalnichevski <olegk at apache.org>

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/Scheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/Scheme.java?rev=744520&r1=744519&r2=744520&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/Scheme.java (original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/Scheme.java Sat Feb 14 16:46:33 2009
@@ -161,7 +161,7 @@
      * @return the given port or the defaultPort
      */
     public final int resolvePort(int port) {
-        return ((port <= 0) || (port > 0xffff)) ? defaultPort : port;
+        return port <= 0 ? defaultPort : port;
     }
 
 

Added: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/scheme/TestScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/scheme/TestScheme.java?rev=744520&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/scheme/TestScheme.java (added)
+++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/scheme/TestScheme.java Sat Feb 14 16:46:33 2009
@@ -0,0 +1,64 @@
+/*
+ * $HeadURL:$
+ * $Revision:$
+ * $Date:$
+ * 
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.conn.scheme;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit tests for {@link Scheme}.
+ */
+public class TestScheme extends TestCase {
+
+    public TestScheme(String testName) {
+        super(testName);
+    }
+
+    public static void main(String args[]) {
+        String[] testCaseName = { TestScheme.class.getName() };
+        junit.textui.TestRunner.main(testCaseName);
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestScheme.class);
+    }
+    
+    public void testPortResolution() {
+        Scheme http = new Scheme("http", PlainSocketFactory.getSocketFactory(), 80);
+        assertEquals(80, http.resolvePort(0));
+        assertEquals(80, http.resolvePort(-1));
+        assertEquals(8080, http.resolvePort(8080));
+        assertEquals(80808080, http.resolvePort(80808080));
+    }
+
+}