jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1697158 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java xdocs/changes.xml
Date Sun, 23 Aug 2015 09:39:20 GMT
Author: fschumacher
Date: Sun Aug 23 09:39:19 2015
New Revision: 1697158

URL: http://svn.apache.org/r1697158
Log:
Use the port from a given host header, if available.

Bugzilla Id: 58201

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1697158&r1=1697157&r2=1697158&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Sun Aug 23 09:39:19 2015
@@ -882,7 +882,7 @@ public class HTTPHC4Impl extends HTTPHCA
                     if (! HTTPConstants.HEADER_CONTENT_LENGTH.equalsIgnoreCase(n)){
                         String v = header.getValue();
                         if (HTTPConstants.HEADER_HOST.equalsIgnoreCase(n)) {
-                            int port = url.getPort();
+                            int port = getPortFromHostHeader(v, url.getPort());
                             v = v.replaceFirst(":\\d+$",""); // remove any port specification
// $NON-NLS-1$ $NON-NLS-2$
                             if (port != -1) {
                                 if (port == url.getDefaultPort()) {
@@ -903,6 +903,28 @@ public class HTTPHC4Impl extends HTTPHCA
     }
 
     /**
+     * Get port from the value of the Host header, or return the given
+     * defaultValue
+     *
+     * @param hostHeaderValue
+     *            value of the http Host header
+     * @param defaultValue
+     *            value to be used, when no port could be extracted from
+     *            hostHeaderValue
+     * @return integer representing the port for the host header
+     */
+    private int getPortFromHostHeader(String hostHeaderValue, int defaultValue) {
+        String[] hostParts = hostHeaderValue.split(":");
+        if (hostParts.length > 1) {
+            String portString = hostParts[hostParts.length - 1];
+            if (portString.matches("^\\d+$")) {
+                return Integer.valueOf(portString);
+            }
+        }
+        return defaultValue;
+    }
+
+    /**
      * Get all the request headers for the <code>HttpMethod</code>
      *
      * @param method

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1697158&r1=1697157&r2=1697158&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sun Aug 23 09:39:19 2015
@@ -145,6 +145,7 @@ Summary
     <li><bug>57921</bug>HTTP/1.1 without keep-alive "Connection" response
header no longer uses infinite keep-alive.</li>
     <li><bug>57956</bug>The hc.parameters reference in jmeter.properties
doesn't work when JMeter is not started in bin.</li>
     <li><bug>58137</bug>JMeter fails to download embedded URLS that contain
illegal characters in URL (it does not escape them).</li>
+    <li><bug>58201</bug>Make usage of port in the host header more consistent
across the different http samplers.</li>
 </ul>
 
 <h3>Other Samplers</h3>



Mime
View raw message