Author: milamber
Date: Wed Sep 14 16:10:06 2011
New Revision: 1170701
URL: http://svn.apache.org/viewvc?rev=1170701&view=rev
Log:
Bug 51775 - Port number duplicates in Host header when capturing by HttpClient
(3.1 and 4.x)
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHCAbstractImpl.java
jakarta/jmeter/trunk/xdocs/changes.xml
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java?rev=1170701&r1=1170700&r2=1170701&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
Wed Sep 14 16:10:06 2011
@@ -592,6 +592,7 @@ public class HTTPHC3Impl extends HTTPHCA
if (! HEADER_CONTENT_LENGTH.equalsIgnoreCase(n)){
String v = header.getValue();
if (HEADER_HOST.equalsIgnoreCase(n)) {
+ v = removePortInHostHeader(v, u.getPort());
method.getParams().setVirtualHost(v);
} else {
method.addRequestHeader(n, v);
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1170701&r1=1170700&r2=1170701&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Wed Sep 14 16:10:06 2011
@@ -638,8 +638,8 @@ public class HTTPHC4Impl extends HTTPHCA
if (! HEADER_CONTENT_LENGTH.equalsIgnoreCase(n)){
String v = header.getValue();
if (HEADER_HOST.equalsIgnoreCase(n)) {
- // TODO is it a bug that HC 4.x does not add the
correct port to the generated Host header?
int port = url.getPort();
+ v = removePortInHostHeader(v, port);
if (port != -1) {
if (port == url.getDefaultPort()) {
port = -1; // no need to specify the port
if it is the default
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHCAbstractImpl.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHCAbstractImpl.java?rev=1170701&r1=1170700&r2=1170701&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHCAbstractImpl.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHCAbstractImpl.java
Wed Sep 14 16:10:06 2011
@@ -152,4 +152,19 @@ public abstract class HTTPHCAbstractImpl
protected static boolean isStaticProxy(String host){
return PROXY_DEFINED && !isNonProxy(host);
}
+
+ /**
+ * In proxy record mode, remove port to host header value
+ *
+ * @param hostHeader
+ * @param port to remove
+ * @return host value without ":port"
+ */
+ protected static String removePortInHostHeader(String hostHeader, int
port) {
+ String rePort = ":" + String.valueOf(port); // $NON-NLS-1$
+ if (hostHeader.trim().endsWith(rePort)) {
+ return hostHeader.replaceFirst(rePort + "$", ""); // $NON-NLS-1$
$NON-NLS-2$
+ }
+ return hostHeader;
+ }
}
Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=1170701&r1=1170700&r2=1170701&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Wed Sep 14 16:10:06 2011
@@ -74,6 +74,7 @@ This can be overridden by setting the JM
<li>Change the default so the HttpClient 4 sampler does not retry</li>
<li>Bug 51752 - HTTP Cache is broken when using "Retrieve all embedded
resources" with concurrent pool</li>
<li>Bug 39219 - HTTP Server: You can't stop it after File->Open</li>
+<li>Bug 51775 - Port number duplicates in Host header when capturing by
HttpClient (3.1 and 4.x)</li>
</ul>
<h3>Other Samplers</h3>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]