HTTPCLIENT-813: Fixed default port resolution. Invalid ports no longer get replaced with the default port value.
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@744520 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eb29d0e8ce
commit
dd5061b2ab
|
@ -9,6 +9,10 @@ bundle combining HttpClient and HttpMime jars.
|
|||
|
||||
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>
|
||||
|
|
|
@ -161,7 +161,7 @@ public final class Scheme {
|
|||
* @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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue