You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2013/08/07 03:11:52 UTC
svn commit: r1511157 - in
/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler:
HTTPAbstractImpl.java HTTPHC3Impl.java HTTPHC4Impl.java
Author: sebb
Date: Wed Aug 7 01:11:52 2013
New Revision: 1511157
URL: http://svn.apache.org/r1511157
Log:
Move common code to super-class
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java?rev=1511157&r1=1511156&r2=1511157&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java Wed Aug 7 01:11:52 2013
@@ -21,7 +21,9 @@ package org.apache.jmeter.protocol.http.
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.InetAddress;
import java.net.URL;
+import java.net.UnknownHostException;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.http.control.AuthManager;
@@ -135,6 +137,20 @@ public abstract class HTTPAbstractImpl i
}
/**
+ * Gets the IP source address (IP spoofing) if one has been provided.
+ *
+ * @return the IP source address to use (or null, if none provided)
+ * @throws UnknownHostException
+ */
+ protected InetAddress getIpSourceAddress() throws UnknownHostException {
+ final String ipSource = getIpSource();
+ if (ipSource.length() > 0) {
+ return InetAddress.getByName(ipSource);
+ }
+ return null;
+ }
+
+ /**
* Invokes {@link HTTPSamplerBase#getProxyHost()}
*/
protected String getProxyHost() {
Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java?rev=1511157&r1=1511156&r2=1511157&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java Wed Aug 7 01:11:52 2013
@@ -442,9 +442,8 @@ public class HTTPHC3Impl extends HTTPHCA
if (localAddress != null){
hc.setLocalAddress(localAddress);
} else {
- final String ipSource = getIpSource();
- if (ipSource.length() > 0) {// Use special field ip source address (for pseudo 'ip spoofing')
- InetAddress inetAddr = InetAddress.getByName(ipSource);
+ final InetAddress inetAddr = getIpSourceAddress();
+ if (inetAddr != null) {// Use special field ip source address (for pseudo 'ip spoofing')
hc.setLocalAddress(inetAddr);
}
}
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=1511157&r1=1511156&r2=1511157&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 Wed Aug 7 01:11:52 2013
@@ -669,9 +669,8 @@ public class HTTPHC4Impl extends HTTPHCA
HttpParams requestParams = httpRequest.getParams();
// Set up the local address if one exists
- final String ipSource = getIpSource();
- if (ipSource.length() > 0) {// Use special field ip source address (for pseudo 'ip spoofing')
- InetAddress inetAddr = InetAddress.getByName(ipSource);
+ final InetAddress inetAddr = getIpSourceAddress();
+ if (inetAddr != null) {// Use special field ip source address (for pseudo 'ip spoofing')
requestParams.setParameter(ConnRoutePNames.LOCAL_ADDRESS, inetAddr);
} else if (localAddress != null){
requestParams.setParameter(ConnRoutePNames.LOCAL_ADDRESS, localAddress);