ASF Bugzilla – Attachment 34752 Details for
Bug 60727
Drop commons-httpclient-3.1 and related elements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch implementing feature
BUG_60727.patch (text/plain), 163.28 KB, created by
UbikLoadPack support
on 2017-02-13 12:43:02 UTC
(
hide
)
Description:
Patch implementing feature
Filename:
MIME Type:
Creator:
UbikLoadPack support
Created:
2017-02-13 12:43:02 UTC
Size:
163.28 KB
patch
obsolete
>Index: LICENSE >=================================================================== >--- LICENSE (revision 1782574) >+++ LICENSE (working copy) >@@ -213,7 +213,6 @@ > * commons-codec-1.10.jar > * commons-collections-3.2.2.jar > * commons-dbcp2-2.1.1.jar >-* commons-httpclient-3.1.jar > * commons-io-2.5.jar > * commons-jexl2-2.1.1.jar > * commons-jexl3-3.0.jar >Index: bin/httpclient.parameters >=================================================================== >--- bin/httpclient.parameters (revision 1782295) >+++ bin/httpclient.parameters (nonexistent) >@@ -1,45 +0,0 @@ >-# 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. >- >-# Properties file used to define additional default Commons HttpClient parameters >-# >-# See: http://hc.apache.org/httpclient-3.x/preference-api.html >-# >-# This file is enabled by setting the JMeter property: httpclient.parameters.file >-# entries are of the form: >-# >-# property=value (for strings) >-# property$Type=value (for other types) >-# >-# where Type can be: >-# Integer >-# Long >-# Boolean >-# HttpVersion >-# >-# N.B. Other types are not yet implemented, so not all parameters are supported >-# >- >-# Examples: >- >-#http.protocol.version$HttpVersion=1.0 >- >-#http.protocol.element-charset=ISO-8859-1 >- >-#http.socket.timeout$Integer=10000 >- >-#http.protocol.reject-relative-redirect$Boolean=true >- >-#http.authentication.preemptive$Boolean=true >\ No newline at end of file >Index: bin/jmeter.properties >=================================================================== >--- bin/jmeter.properties (revision 1782694) >+++ bin/jmeter.properties (working copy) >@@ -300,13 +300,11 @@ > #http.java.sampler.retries=0 > > #--------------------------------------------------------------------------- >-# Following properties apply to both Commons and Apache HttpClient >+# Following properties apply to Apache HttpClient > #--------------------------------------------------------------------------- > > # set the socket timeout (or use the parameter http.socket.timeout) >-# for AJP Sampler and HttpClient3 implementation. >-# Note for HttpClient3 implementation it is better to use GUI to set timeout >-# or use http.socket.timeout in httpclient.parameters >+# for AJP Sampler implementation. > # Value is in milliseconds > #httpclient.timeout=0 > # 0 == no timeout >@@ -368,19 +366,6 @@ > #httpclient4.max_body_retain_size=32768 > > #--------------------------------------------------------------------------- >-# Apache HttpComponents Commons HTTPClient configuration (HTTPClient 3.1) >-# DEPRECATED >-#--------------------------------------------------------------------------- >- >-# define a properties file for overriding Commons HttpClient parameters >-# See: http://hc.apache.org/httpclient-3.x/preference-api.html >-# Uncomment this line if you put anything in httpclient.parameters file >-#httpclient.parameters.file=httpclient.parameters >- >-# Number of retries to attempt (default 0) >-#httpclient3.retrycount=0 >- >-#--------------------------------------------------------------------------- > # HTTP Cache Manager configuration > #--------------------------------------------------------------------------- > # >@@ -438,6 +423,7 @@ > #jmeter.save.saveservice.subresults=true > #jmeter.save.saveservice.assertions=true > #jmeter.save.saveservice.latency=true >+# Only available with HttpClient4 > #jmeter.save.saveservice.connect_time=true > #jmeter.save.saveservice.samplerData=false > #jmeter.save.saveservice.responseHeaders=false >@@ -538,11 +524,6 @@ > #or > #jmeter.httpsampler=Java > # >-# Apache HTTPClient: >-#jmeter.httpsampler=HTTPSampler2 >-#or >-#jmeter.httpsampler=HttpClient3.1 >-# > # HttpClient4.x > #jmeter.httpsampler=HttpClient4 > >Index: bin/saveservice.properties >=================================================================== >--- bin/saveservice.properties (revision 1782633) >+++ bin/saveservice.properties (working copy) >@@ -288,8 +288,12 @@ > SMIMEAssertionGui=org.apache.jmeter.assertions.gui.SMIMEAssertionGui > SmtpSampler=org.apache.jmeter.protocol.smtp.sampler.SmtpSampler > SmtpSamplerGui=org.apache.jmeter.protocol.smtp.sampler.gui.SmtpSamplerGui >+ >+# removed in 3.2, class was deleted in r > SoapSampler=org.apache.jmeter.protocol.http.sampler.SoapSampler >+# removed in 3.2, class was deleted in r > SoapSamplerGui=org.apache.jmeter.protocol.http.control.gui.SoapSamplerGui >+ > # removed in 3.1, class was deleted in r1763837 > SplineVisualizer=org.apache.jmeter.visualizers.SplineVisualizer > # Originally deleted in r397955 as class is obsolete; needed for compat. >Index: bin/upgrade.properties >=================================================================== >--- bin/upgrade.properties (revision 1782295) >+++ bin/upgrade.properties (working copy) >@@ -115,4 +115,9 @@ > > # removed in 3.2 class was deleted in r > org.apache.jmeter.visualizers.MonitorStats=org.apache.jmeter.config.ConfigTestElement >-org.apache.jmeter.visualizers.MonitorHealthVisualizer=org.apache.jmeter.config.gui.ObsoleteGui >\ No newline at end of file >+org.apache.jmeter.visualizers.MonitorHealthVisualizer=org.apache.jmeter.config.gui.ObsoleteGui >+ >+# removed in 3.2 class was deleted in r >+org.apache.jmeter.protocol.http.sampler.HTTPSampler2=org.apache.jmeter.config.ConfigTestElement >+org.apache.jmeter.protocol.http.sampler.SoapSampler=org.apache.jmeter.config.ConfigTestElement >+org.apache.jmeter.protocol.http.control.gui.SoapSamplerGui=org.apache.jmeter.config.gui.ObsoleteGui >\ No newline at end of file >Index: build.properties >=================================================================== >--- build.properties (revision 1782592) >+++ build.properties (working copy) >@@ -100,11 +100,6 @@ > commons-dbcp2.loc = ${maven2.repo}/org/apache/commons/commons-dbcp2/${commons-dbcp2.version} > commons-dbcp2.md5 = 298897b1e785b933b0522351871cf7ae > >-commons-httpclient.version = 3.1 >-commons-httpclient.jar = commons-httpclient-${commons-httpclient.version}.jar >-commons-httpclient.loc = ${maven2.repo}/commons-httpclient/commons-httpclient/${commons-httpclient.version} >-commons-httpclient.md5 = 8AD8C9229EF2D59AB9F59F7050E846A5 >- > commons-io.version = 2.5 > commons-io.jar = commons-io-${commons-io.version}.jar > commons-io.loc = ${maven2.repo}/commons-io/commons-io/${commons-io.version} >Index: build.xml >=================================================================== >--- build.xml (revision 1782633) >+++ build.xml (working copy) >@@ -383,7 +383,6 @@ > <include name="${lib.dir}/${commons-codec.jar}"/> > <include name="${lib.dir}/${commons-collections.jar}"/> > <include name="${lib.dir}/${commons-dbcp2.jar}"/> >- <include name="${lib.dir}/${commons-httpclient.jar}"/> > <include name="${lib.dir}/${commons-io.jar}"/> > <include name="${lib.dir}/${commons-jexl2.jar}"/> > <include name="${lib.dir}/${commons-jexl3.jar}"/> >@@ -464,7 +463,6 @@ > <pathelement location="${lib.dir}/${commons-codec.jar}"/> > <pathelement location="${lib.dir}/${commons-collections.jar}"/> > <pathelement location="${lib.dir}/${commons-dbcp2.jar}"/> >- <pathelement location="${lib.dir}/${commons-httpclient.jar}"/> > <pathelement location="${lib.dir}/${commons-io.jar}"/> > <pathelement location="${lib.dir}/${commons-jexl2.jar}"/> > <pathelement location="${lib.dir}/${commons-jexl3.jar}"/> >@@ -3020,7 +3018,6 @@ > <process_jarfile jarname="commons-codec"/> > <process_jarfile jarname="commons-collections"/> > <process_jarfile jarname="commons-dbcp2"/> >- <process_jarfile jarname="commons-httpclient"/> > <process_jarfile jarname="commons-io"/> > <process_jarfile jarname="commons-jexl2"/> > <process_jarfile jarname="commons-jexl3"/> >@@ -3119,6 +3116,8 @@ > <fileset dir="${lib.dir}" includes="slf4j-nop-1.7.13.jar"/> > <!-- tidy up unused commons-logging jar --> > <fileset dir="${lib.dir}" includes="commons-logging-1.2.jar"/> >+ <!-- tidy up unused commons-httpclient jar --> >+ <fileset dir="${lib.dir}" includes="commons-httpclient-3.1.jar"/> > <!-- tidy up unused htmlparser jars --> > <fileset dir="${lib.dir}" includes="htmllexer-2.1.jar htmlparser-2.1.jar"/> > <!-- tidy up unused logkit jars --> >Index: eclipse.classpath >=================================================================== >--- eclipse.classpath (revision 1782574) >+++ eclipse.classpath (working copy) >@@ -53,7 +53,6 @@ > <classpathentry kind="lib" path="lib/commons-codec-1.10.jar"/> > <classpathentry kind="lib" path="lib/commons-collections-3.2.2.jar"/> > <classpathentry kind="lib" path="lib/commons-dbcp2-2.1.1.jar"/> >- <classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/> > <classpathentry kind="lib" path="lib/commons-io-2.5.jar"/> > <classpathentry kind="lib" path="lib/commons-jexl-2.1.1.jar"/> > <classpathentry kind="lib" path="lib/commons-jexl3-3.0.jar"/> >Index: lib/aareadme.txt >=================================================================== >--- lib/aareadme.txt (revision 1782574) >+++ lib/aareadme.txt (working copy) >@@ -33,8 +33,7 @@ > commons-codec-1.10 > ----------------- > http://commons.apache.org/downloads/download_codec.cgi >-- used by commons-httpclient-3.1 >-- also HtmlParserTester for Base64 >+- Used by HtmlParserTester for Base64 > > commons-collections-3.2.2 > ------------------------- >@@ -42,12 +41,6 @@ > - ListenerNotifier > - Anakia > >-commons-httpclient-3.1 >----------------------- >-http://hc.apache.org/downloads.cgi >-- httpclient version of HTTP sampler >-- Cookie manager implementation >- > commons-io-2.5 > -------------- > http://commons.apache.org/downloads/download_io.cgi >Index: licenses/bin/README.txt >=================================================================== >--- licenses/bin/README.txt (revision 1781763) >+++ licenses/bin/README.txt (working copy) >@@ -8,7 +8,6 @@ > commons-codec-1.10.jar > commons-collections-3.2.2.jar > commons-dbcp2-2.1.1.jar >-commons-httpclient-3.1.jar > commons-io-2.5.jar > commons-jexl-2.1.1.jar > commons-jexl3-3.0.jar >Index: res/maven/ApacheJMeter_parent.pom >=================================================================== >--- res/maven/ApacheJMeter_parent.pom (revision 1782574) >+++ res/maven/ApacheJMeter_parent.pom (working copy) >@@ -63,7 +63,6 @@ > <commons-codec.version>1.10</commons-codec.version> > <commons-collections.version>3.2.2</commons-collections.version> > <commons-dbcp2.version>2.1.1</commons-dbcp2.version> >- <commons-httpclient.version>3.1</commons-httpclient.version> > <commons-io.version>2.5</commons-io.version> > <commons-jexl2.version>2.1.1</commons-jexl2.version> > <commons-jexl3.version>3.0</commons-jexl3.version> >@@ -174,11 +173,6 @@ > <version>${commons-dbcp2.version}</version> > </dependency> > <dependency> >- <groupId>commons-httpclient</groupId> >- <artifactId>commons-httpclient</artifactId> >- <version>${commons-httpclient.version}</version> >- </dependency> >- <dependency> > <groupId>commons-io</groupId> > <artifactId>commons-io</artifactId> > <version>${commons-io.version}</version> >Index: src/core/org/apache/jmeter/save/SaveService.java >=================================================================== >--- src/core/org/apache/jmeter/save/SaveService.java (revision 1782633) >+++ src/core/org/apache/jmeter/save/SaveService.java (working copy) >@@ -154,7 +154,7 @@ > private static String fileVersion = ""; // computed from saveservice.properties file// $NON-NLS-1$ > // Must match the sha1 checksum of the file saveservice.properties (without newline character), > // used to ensure saveservice.properties and SaveService are updated simultaneously >- static final String FILEVERSION = "09831d0774c9e7131205e2f5c614abe0c3effba6"; // Expected value $NON-NLS-1$ >+ static final String FILEVERSION = "672a997ce15720edd5ac94b288fd19f80202e4d3"; // Expected value $NON-NLS-1$ > > private static String fileEncoding = ""; // read from properties file// $NON-NLS-1$ > >Index: src/core/org/apache/jmeter/util/HttpSSLProtocolSocketFactory.java >=================================================================== >--- src/core/org/apache/jmeter/util/HttpSSLProtocolSocketFactory.java (revision 1782633) >+++ src/core/org/apache/jmeter/util/HttpSSLProtocolSocketFactory.java (working copy) >@@ -19,9 +19,7 @@ > > import java.io.IOException; > import java.net.InetAddress; >-import java.net.InetSocketAddress; > import java.net.Socket; >-import java.net.SocketAddress; > import java.net.UnknownHostException; > import java.security.GeneralSecurityException; > >@@ -29,9 +27,6 @@ > import javax.net.ssl.SSLSocket; > import javax.net.ssl.SSLSocketFactory; > >-import org.apache.commons.httpclient.ConnectTimeoutException; >-import org.apache.commons.httpclient.params.HttpConnectionParams; >-import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; > import org.slf4j.Logger; > import org.slf4j.LoggerFactory; > >@@ -42,8 +37,7 @@ > */ > > public class HttpSSLProtocolSocketFactory >- extends SSLSocketFactory // for java sockets >- implements SecureProtocolSocketFactory { // for Commons Httpclient sockets >+ extends SSLSocketFactory {// for java sockets > > private static final Logger log = LoggerFactory.getLogger(HttpSSLProtocolSocketFactory.class); > >@@ -121,64 +115,6 @@ > } > > /** >- * Attempts to get a new socket connection to the given host within the given time limit. >- * >- * @param host the host name/IP >- * @param port the port on the host >- * @param localAddress the local host name/IP to bind the socket to >- * @param localPort the port on the local machine >- * @param params {@link HttpConnectionParams Http connection parameters} >- * >- * @return Socket a new socket >- * >- * @throws IOException if an I/O error occurs while creating the socket >- * @throws UnknownHostException if the IP address of the host cannot be >- * determined >- */ >- @Override >- public Socket createSocket( >- final String host, >- final int port, >- final InetAddress localAddress, >- final int localPort, >- final HttpConnectionParams params >- ) throws IOException, UnknownHostException, ConnectTimeoutException { >- if (params == null) { >- throw new IllegalArgumentException("Parameters may not be null"); >- } >- int timeout = params.getConnectionTimeout(); >- >- SSLSocketFactory sslfac = getSSLSocketFactory(); >- Socket socket; >- if (timeout == 0) { >- socket = sslfac.createSocket(host, port, localAddress, localPort); >- } else { >- socket = sslfac.createSocket(); >- SocketAddress localaddr = new InetSocketAddress(localAddress, localPort); >- SocketAddress remoteaddr = new InetSocketAddress(host, port); >- socket.bind(localaddr); >- socket.connect(remoteaddr, timeout); >- } >- setSocket(socket); >- return wrapSocket(socket); >- } >- >- /** >- * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int) >- */ >- @Override >- public Socket createSocket(String host, int port) >- throws IOException, UnknownHostException { >- SSLSocketFactory sslfac = getSSLSocketFactory(); >- Socket sock = sslfac.createSocket( >- host, >- port >- ); >- setSocket(sock); >- return wrapSocket(sock); >- } >- >- /** > * @see javax.net.SocketFactory#createSocket() > */ > @Override >@@ -189,49 +125,7 @@ > return wrapSocket(sock); > } > >- /** >- * @see SecureProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean) >- */ >- @Override >- public Socket createSocket( >- Socket socket, >- String host, >- int port, >- boolean autoClose) >- throws IOException, UnknownHostException { >- SSLSocketFactory sslfac = getSSLSocketFactory(); >- Socket sock = sslfac.createSocket( >- socket, >- host, >- port, >- autoClose >- ); >- setSocket(sock); >- return wrapSocket(sock); >- } > >- /** >- * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int) >- */ >- @Override >- public Socket createSocket( >- String host, >- int port, >- InetAddress clientHost, >- int clientPort) >- throws IOException, UnknownHostException { >- >- SSLSocketFactory sslfac = getSSLSocketFactory(); >- Socket sock = sslfac.createSocket( >- host, >- port, >- clientHost, >- clientPort >- ); >- setSocket(sock); >- return wrapSocket(sock); >- } >- > @Override > public Socket createSocket(InetAddress host, int port) throws IOException { > SSLSocketFactory sslfac = getSSLSocketFactory(); >@@ -267,4 +161,30 @@ > return new String[] {}; > } > } >+ >+ @Override >+ public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException { >+ SSLSocketFactory sslfac = getSSLSocketFactory(); >+ Socket sock=sslfac.createSocket(s, host,port, autoClose); >+ setSocket(sock); >+ return wrapSocket(sock); >+ } >+ >+ @Override >+ public Socket createSocket(String host, int port) throws IOException, UnknownHostException { >+ SSLSocketFactory sslfac = getSSLSocketFactory(); >+ Socket sock=sslfac.createSocket(host,port); >+ setSocket(sock); >+ return wrapSocket(sock); >+ } >+ >+ @Override >+ public Socket createSocket(String host, int port, InetAddress inetAddress, int localPort) >+ throws IOException, UnknownHostException { >+ SSLSocketFactory sslfac = getSSLSocketFactory(); >+ Socket sock=sslfac.createSocket(host, port, inetAddress, localPort); >+ setSocket(sock); >+ return wrapSocket(sock); >+ >+ } > } >Index: src/core/org/apache/jmeter/util/JsseSSLManager.java >=================================================================== >--- src/core/org/apache/jmeter/util/JsseSSLManager.java (revision 1782633) >+++ src/core/org/apache/jmeter/util/JsseSSLManager.java (working copy) >@@ -39,8 +39,6 @@ > import javax.net.ssl.X509KeyManager; > import javax.net.ssl.X509TrustManager; > >-import org.apache.commons.httpclient.protocol.Protocol; >-import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; > import org.apache.jmeter.util.keystore.JmeterKeyStore; > import org.slf4j.Logger; > import org.slf4j.LoggerFactory; >@@ -124,14 +122,6 @@ > } > }); > >- /* >- * Also set up HttpClient defaults >- */ >- Protocol protocol = new Protocol( >- JsseSSLManager.HTTPS, >- (ProtocolSocketFactory) new HttpSSLProtocolSocketFactory(this, CPS), >- 443); >- Protocol.registerProtocol(JsseSSLManager.HTTPS, protocol); > log.debug("SSL stuff all set"); > } catch (GeneralSecurityException ex) { > log.error("Could not set up SSLContext", ex); >Index: src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java (revision 1782633) >+++ src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java (working copy) >@@ -28,8 +28,6 @@ > import java.util.Map; > > import org.apache.commons.collections.map.LRUMap; >-import org.apache.commons.httpclient.HttpMethod; >-import org.apache.commons.httpclient.URIException; > import org.apache.commons.lang3.StringUtils; > import org.apache.http.HttpResponse; > import org.apache.http.client.methods.HttpRequestBase; >@@ -42,8 +40,8 @@ > import org.apache.jmeter.testelement.TestStateListener; > import org.apache.jmeter.testelement.property.BooleanProperty; > import org.apache.jmeter.util.JMeterUtils; >-import org.slf4j.LoggerFactory; > import org.slf4j.Logger; >+import org.slf4j.LoggerFactory; > > /** > * Handles HTTP Caching >@@ -146,39 +144,6 @@ > > /** > * Save the Last-Modified, Etag, and Expires headers if the result is >- * cacheable. Version for Commons HttpClient implementation. >- * >- * @param method >- * {@link HttpMethod} to get header information from >- * @param res >- * result to decide if result is cacheable >- * @throws URIException >- * if extraction of the uri from <code>method</code> fails >- * @deprecated HC3.1 will be dropped in upcoming version >- */ >- @Deprecated >- public void saveDetails(HttpMethod method, HTTPSampleResult res) throws URIException{ >- if (isCacheable(res) && !hasVaryHeader(method)){ >- String lastModified = getHeader(method ,HTTPConstants.LAST_MODIFIED); >- String expires = getHeader(method ,HTTPConstants.EXPIRES); >- String etag = getHeader(method ,HTTPConstants.ETAG); >- String url = method.getURI().toString(); >- String cacheControl = getHeader(method, HTTPConstants.CACHE_CONTROL); >- String date = getHeader(method, HTTPConstants.DATE); >- setCache(lastModified, cacheControl, expires, etag, url, date); >- } >- } >- >- /** >- * @deprecated HC3.1 will be dropped in upcoming version >- */ >- @Deprecated >- private boolean hasVaryHeader(HttpMethod method) { >- return getHeader(method, HTTPConstants.VARY) != null; >- } >- >- /** >- * Save the Last-Modified, Etag, and Expires headers if the result is > * cacheable. Version for Apache HttpClient implementation. > * > * @param method >@@ -276,19 +241,6 @@ > getCache().put(url, new CacheEntry(lastModified, expiresDate, etag)); > } > >- /** >- * Helper method to deal with missing headers - Commons HttpClient >- * @param method Http method >- * @param name Header name >- * @return Header value >- * @deprecated HC3.1 will be dropped in upcoming version >- */ >- @Deprecated >- private String getHeader(HttpMethod method, String name){ >- org.apache.commons.httpclient.Header hdr = method.getResponseHeader(name); >- return hdr != null ? hdr.getValue() : null; >- } >- > // Apache HttpClient > private String getHeader(HttpResponse method, String name) { > org.apache.http.Header hdr = method.getLastHeader(name); >@@ -323,35 +275,6 @@ > * <li>If-Modified-Since</li> > * <li>If-None-Match</li> > * </ul> >- * Commons HttpClient version >- * @param url URL to look up in cache >- * @param method where to set the headers >- * @deprecated HC3.1 will be dropped in upcoming version >- */ >- @Deprecated >- public void setHeaders(URL url, HttpMethod method) { >- CacheEntry entry = getCache().get(url.toString()); >- if (log.isDebugEnabled()){ >- log.debug(method.getName()+"(OACH) "+url.toString()+" "+entry); >- } >- if (entry != null){ >- final String lastModified = entry.getLastModified(); >- if (lastModified != null){ >- method.setRequestHeader(HTTPConstants.IF_MODIFIED_SINCE, lastModified); >- } >- final String etag = entry.getEtag(); >- if (etag != null){ >- method.setRequestHeader(HTTPConstants.IF_NONE_MATCH, etag); >- } >- } >- } >- >- /** >- * Check the cache, and if there is a match, set the headers: >- * <ul> >- * <li>If-Modified-Since</li> >- * <li>If-None-Match</li> >- * </ul> > * Apache HttpClient version. > * @param url {@link URL} to look up in cache > * @param request where to set the headers >Index: src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java (revision 1782633) >+++ src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java (working copy) >@@ -122,7 +122,7 @@ > * @deprecated not intended for use outside this class (should have been created private) > */ > @Deprecated >- public static final String DEFAULT_IMPLEMENTATION = HC3CookieHandler.class.getName(); >+ public static final String DEFAULT_IMPLEMENTATION = "org.apache.jmeter.protocol.http.control.HC3CookieHandler"; > > public CookieManager() { > clearCookies(); // Ensure that there is always a collection available >Index: src/protocol/http/org/apache/jmeter/protocol/http/control/HC3CookieHandler.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/control/HC3CookieHandler.java (revision 1782633) >+++ src/protocol/http/org/apache/jmeter/protocol/http/control/HC3CookieHandler.java (nonexistent) >@@ -1,227 +0,0 @@ >-/* >- * 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. >- * >- */ >- >-package org.apache.jmeter.protocol.http.control; >- >-import java.net.URL; >-import java.util.Date; >- >-import org.apache.commons.httpclient.cookie.CookiePolicy; >-import org.apache.commons.httpclient.cookie.CookieSpec; >-import org.apache.commons.httpclient.cookie.MalformedCookieException; >-import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; >-import org.apache.jmeter.testelement.property.CollectionProperty; >-import org.apache.jmeter.testelement.property.JMeterProperty; >-import org.slf4j.LoggerFactory; >-import org.slf4j.Logger; >- >-/** >- * HTTPClient 3.1 implementation >- * @deprecated since 3.0, will be removed in next version >- */ >-@Deprecated >-public class HC3CookieHandler implements CookieHandler { >- private static final Logger log = LoggerFactory.getLogger(HC3CookieHandler.class); >- >- static final String DEFAULT_POLICY_NAME = "compatibility"; >- private static final String[] AVAILABLE_POLICIES = new String[] { >- DEFAULT_POLICY_NAME, >- "default", >- "rfc2109", >- "rfc2965", >- "ignorecookies", >- "netscape" >- }; >- >- private final transient CookieSpec cookieSpec; >- >- /** >- * Default constructor that uses {@link HC3CookieHandler#DEFAULT_POLICY_NAME} >- */ >- public HC3CookieHandler() { >- this(DEFAULT_POLICY_NAME); >- } >- >- /** >- * @param policy >- * cookie policy to which to conform (see >- * {@link CookiePolicy#getCookieSpec(String)} >- */ >- public HC3CookieHandler(String policy) { >- super(); >- this.cookieSpec = CookiePolicy.getCookieSpec(policy); >- } >- >- /** >- * Create an HttpClient cookie from a JMeter cookie >- */ >- private org.apache.commons.httpclient.Cookie makeCookie(Cookie jmc){ >- long exp = jmc.getExpiresMillis(); >- org.apache.commons.httpclient.Cookie ret= >- new org.apache.commons.httpclient.Cookie( >- jmc.getDomain(), >- jmc.getName(), >- jmc.getValue(), >- jmc.getPath(), >- exp > 0 ? new Date(exp) : null, // use null for no expiry >- jmc.getSecure() >- ); >- ret.setPathAttributeSpecified(jmc.isPathSpecified()); >- ret.setDomainAttributeSpecified(jmc.isDomainSpecified()); >- ret.setVersion(jmc.getVersion()); >- return ret; >- } >- /** >- * Get array of valid HttpClient cookies for the URL >- * >- * @param cookiesCP cookies to consider >- * @param url the target URL >- * @param allowVariableCookie flag whether to allow jmeter variables in cookie values >- * @return array of HttpClient cookies >- * >- */ >- org.apache.commons.httpclient.Cookie[] getCookiesForUrl( >- CollectionProperty cookiesCP, >- URL url, >- boolean allowVariableCookie){ >- org.apache.commons.httpclient.Cookie[] cookies = >- new org.apache.commons.httpclient.Cookie[cookiesCP.size()]; >- int i = 0; >- for (JMeterProperty jMeterProperty : cookiesCP) { >- Cookie jmcookie = (Cookie) jMeterProperty.getObjectValue(); >- // Set to running version, to allow function evaluation for the cookie values (bug 28715) >- if (allowVariableCookie) { >- jmcookie.setRunningVersion(true); >- } >- cookies[i++] = makeCookie(jmcookie); >- if (allowVariableCookie) { >- jmcookie.setRunningVersion(false); >- } >- } >- String host = url.getHost(); >- String protocol = url.getProtocol(); >- int port= HTTPSamplerBase.getDefaultPort(protocol,url.getPort()); >- String path = url.getPath(); >- boolean secure = HTTPSamplerBase.isSecure(protocol); >- return cookieSpec.match(host, port, path, secure, cookies); >- } >- >- /** >- * Find cookies applicable to the given URL and build the Cookie header from >- * them. >- * >- * @param url >- * URL of the request to which the returned header will be added. >- * @return the value string for the cookie header (goes after "Cookie: "). >- */ >- @Override >- public String getCookieHeaderForURL( >- CollectionProperty cookiesCP, >- URL url, >- boolean allowVariableCookie) { >- org.apache.commons.httpclient.Cookie[] c = >- getCookiesForUrl(cookiesCP, url, allowVariableCookie); >- int count = c.length; >- boolean debugEnabled = log.isDebugEnabled(); >- if (debugEnabled){ >- log.debug("Found "+count+" cookies for "+url.toExternalForm()); >- } >- if (count <=0){ >- return null; >- } >- String hdr=cookieSpec.formatCookieHeader(c).getValue(); >- if (debugEnabled){ >- log.debug("Cookie: "+hdr); >- } >- return hdr; >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public void addCookieFromHeader(CookieManager cookieManager, >- boolean checkCookies,String cookieHeader, URL url){ >- boolean debugEnabled = log.isDebugEnabled(); >- if (debugEnabled) { >- log.debug("Received Cookie: " + cookieHeader + " From: " + url.toExternalForm()); >- } >- String protocol = url.getProtocol(); >- String host = url.getHost(); >- int port= HTTPSamplerBase.getDefaultPort(protocol,url.getPort()); >- String path = url.getPath(); >- boolean isSecure=HTTPSamplerBase.isSecure(protocol); >- org.apache.commons.httpclient.Cookie[] cookies= null; >- try { >- cookies = cookieSpec.parse(host, port, path, isSecure, cookieHeader); >- } catch (MalformedCookieException | IllegalArgumentException e) { >- log.warn(cookieHeader+e.getLocalizedMessage()); >- } >- if (cookies == null) { >- return; >- } >- for(org.apache.commons.httpclient.Cookie cookie : cookies){ >- try { >- if (checkCookies) { >- cookieSpec.validate(host, port, path, isSecure, cookie); >- } >- Date expiryDate = cookie.getExpiryDate(); >- long exp = 0; >- if (expiryDate!= null) { >- exp=expiryDate.getTime(); >- } >- Cookie newCookie = new Cookie( >- cookie.getName(), >- cookie.getValue(), >- cookie.getDomain(), >- cookie.getPath(), >- cookie.getSecure(), >- exp / 1000, >- cookie.isPathAttributeSpecified(), >- cookie.isDomainAttributeSpecified() >- ); >- >- // Store session cookies as well as unexpired ones >- if (exp == 0 || exp >= System.currentTimeMillis()) { >- newCookie.setVersion(cookie.getVersion()); >- cookieManager.add(newCookie); // Has its own debug log; removes matching cookies >- } else { >- cookieManager.removeMatchingCookies(newCookie); >- if (debugEnabled){ >- log.debug("Dropping expired Cookie: "+newCookie.toString()); >- } >- } >- } catch (MalformedCookieException e) { // This means the cookie was wrong for the URL >- log.warn("Not storing invalid cookie: <"+cookieHeader+"> for URL "+url+" ("+e.getLocalizedMessage()+")"); >- } catch (IllegalArgumentException e) { >- log.warn(cookieHeader+e.getLocalizedMessage()); >- } >- } >- >- } >- >- @Override >- public String getDefaultPolicy() { >- return DEFAULT_POLICY_NAME; >- } >- >- @Override >- public String[] getPolicies() { >- return AVAILABLE_POLICIES; >- } >-} >Index: src/protocol/http/org/apache/jmeter/protocol/http/control/HC4CookieHandler.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/control/HC4CookieHandler.java (revision 1782633) >+++ src/protocol/http/org/apache/jmeter/protocol/http/control/HC4CookieHandler.java (working copy) >@@ -48,8 +48,8 @@ > import org.apache.jmeter.protocol.http.util.HTTPConstants; > import org.apache.jmeter.testelement.property.CollectionProperty; > import org.apache.jmeter.testelement.property.JMeterProperty; >-import org.slf4j.LoggerFactory; > import org.slf4j.Logger; >+import org.slf4j.LoggerFactory; > > public class HC4CookieHandler implements CookieHandler { > private static final Logger log = LoggerFactory.getLogger(HC4CookieHandler.class); >@@ -96,7 +96,7 @@ > > public HC4CookieHandler(String policy) { > super(); >- if (policy.equals(org.apache.commons.httpclient.cookie.CookiePolicy.DEFAULT)) { // tweak diff HC3 vs HC4 >+ if (policy.equalsIgnoreCase("default")) { // tweak diff HC3 vs HC4 > policy = CookieSpecs.DEFAULT; > } > HttpClientContext context = HttpClientContext.create(); >Index: src/protocol/http/org/apache/jmeter/protocol/http/control/gui/SoapSamplerGui.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/control/gui/SoapSamplerGui.java (revision 1782633) >+++ src/protocol/http/org/apache/jmeter/protocol/http/control/gui/SoapSamplerGui.java (nonexistent) >@@ -1,170 +0,0 @@ >-/* >- * 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. >- * >- */ >- >-package org.apache.jmeter.protocol.http.control.gui; >- >-import java.awt.BorderLayout; >-import java.awt.Dimension; >-import java.awt.GridBagLayout; >-import java.awt.GridBagConstraints; >- >-import javax.swing.JCheckBox; >-import javax.swing.JPanel; >- >-import org.apache.jmeter.protocol.http.sampler.SoapSampler; >-import org.apache.jmeter.samplers.gui.AbstractSamplerGui; >-import org.apache.jmeter.testelement.TestElement; >-import org.apache.jmeter.util.JMeterUtils; >-import org.apache.jmeter.gui.util.FilePanel; >-import org.apache.jorphan.gui.JLabeledTextArea; >-import org.apache.jorphan.gui.JLabeledTextField; >- >-public class SoapSamplerGui extends AbstractSamplerGui { >- private static final long serialVersionUID = 240L; >- >- private JLabeledTextField urlField; >- private JLabeledTextField soapAction; >- private JCheckBox sendSoapAction; >- private JCheckBox useKeepAlive; >- private JLabeledTextArea soapXml; >- >- private FilePanel soapXmlFile = new FilePanel(); >- >- public SoapSamplerGui() { >- init(); >- } >- >- @Override >- public String getLabelResource() { >- return "soap_sampler_title"; //$NON-NLS-1$ >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public TestElement createTestElement() { >- SoapSampler sampler = new SoapSampler(); >- modifyTestElement(sampler); >- return sampler; >- } >- >- /** >- * Modifies a given TestElement to mirror the data in the gui components. >- * >- * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement) >- */ >- @Override >- public void modifyTestElement(TestElement s) { >- super.configureTestElement(s); >- if (s instanceof SoapSampler) { >- SoapSampler sampler = (SoapSampler) s; >- sampler.setURLData(urlField.getText()); >- sampler.setXmlData(soapXml.getText()); >- sampler.setXmlFile(soapXmlFile.getFilename()); >- sampler.setSOAPAction(soapAction.getText()); >- sampler.setSendSOAPAction(sendSoapAction.isSelected()); >- sampler.setUseKeepAlive(useKeepAlive.isSelected()); >- } >- } >- >- /** >- * Implements JMeterGUIComponent.clearGui >- */ >- @Override >- public void clearGui() { >- super.clearGui(); >- >- urlField.setText(""); //$NON-NLS-1$ >- soapAction.setText(""); //$NON-NLS-1$ >- soapXml.setText(""); //$NON-NLS-1$ >- sendSoapAction.setSelected(true); >- soapXmlFile.setFilename(""); //$NON-NLS-1$ >- useKeepAlive.setSelected(false); >- } >- >- private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final) >- setLayout(new BorderLayout()); >- setBorder(makeBorder()); >- >- add(makeTitlePanel(), BorderLayout.NORTH); >- >- urlField = new JLabeledTextField(JMeterUtils.getResString("url"), 10); //$NON-NLS-1$ >- soapXml = new JLabeledTextArea(JMeterUtils.getResString("soap_data_title")); //$NON-NLS-1$ >- soapAction = new JLabeledTextField("", 10); //$NON-NLS-1$ >- sendSoapAction = new JCheckBox(JMeterUtils.getResString("soap_send_action"), true); //$NON-NLS-1$ >- useKeepAlive = new JCheckBox(JMeterUtils.getResString("use_keepalive")); // $NON-NLS-1$ >- >- JPanel mainPanel = new JPanel(new BorderLayout()); >- JPanel soapActionPanel = new JPanel(); >- soapActionPanel.setLayout(new GridBagLayout()); >- GridBagConstraints c = new GridBagConstraints(); >- c.fill = GridBagConstraints.HORIZONTAL; >- c.gridwidth = 2; >- c.gridx = 0; >- c.gridy = 0; >- c.weightx = 1; >- soapActionPanel.add(urlField, c); >- c.fill = GridBagConstraints.NONE; >- c.gridwidth = 1; >- c.gridy = 1; >- c.weightx = 0; >- soapActionPanel.add(sendSoapAction, c); >- c.gridx = 1; >- c.fill = GridBagConstraints.HORIZONTAL; >- c.weightx = 1; >- soapActionPanel.add(soapAction, c); >- >- c.fill = GridBagConstraints.HORIZONTAL; >- c.gridwidth = 2; >- c.gridy = 2; >- c.gridx = 0; >- soapActionPanel.add(useKeepAlive, c); >- >- mainPanel.add(soapActionPanel, BorderLayout.NORTH); >- mainPanel.add(soapXml, BorderLayout.CENTER); >- mainPanel.add(soapXmlFile, BorderLayout.SOUTH); >- >- sendSoapAction.addActionListener(e -> soapAction.setEnabled(sendSoapAction.isSelected())); >- >- add(mainPanel, BorderLayout.CENTER); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public void configure(TestElement el) { >- super.configure(el); >- SoapSampler sampler = (SoapSampler) el; >- urlField.setText(sampler.getURLData()); >- sendSoapAction.setSelected(sampler.getSendSOAPAction()); >- soapAction.setText(sampler.getSOAPAction()); >- soapXml.setText(sampler.getXmlData()); >- soapXmlFile.setFilename(sampler.getXmlFile()); >- useKeepAlive.setSelected(sampler.getUseKeepAlive()); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public Dimension getPreferredSize() { >- return getMinimumSize(); >- } >-} >Index: src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java (revision 1781963) >+++ src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java (working copy) >@@ -95,12 +95,12 @@ > import org.apache.jmeter.util.JMeterUtils; > import org.apache.jmeter.visualizers.Visualizer; > import org.apache.jorphan.exec.KeyToolUtils; >-import org.slf4j.LoggerFactory; > import org.apache.jorphan.util.JOrphanUtils; >-import org.slf4j.Logger; > import org.apache.oro.text.MalformedCachePatternException; > import org.apache.oro.text.regex.Pattern; > import org.apache.oro.text.regex.Perl5Compiler; >+import org.slf4j.Logger; >+import org.slf4j.LoggerFactory; > > > /** >@@ -447,12 +447,16 @@ > public String getSamplerTypeName() { > // Convert the old numeric types - just in case someone wants to reload the workbench > String type = getPropertyAsString(SAMPLER_TYPE_NAME); >- if (SAMPLER_TYPE_HTTP_SAMPLER_JAVA.equals(type)){ >- type = HTTPSamplerFactory.IMPL_JAVA; >- } else if (SAMPLER_TYPE_HTTP_SAMPLER_HC3_1.equals(type)){ >- type = HTTPSamplerFactory.IMPL_HTTP_CLIENT3_1; >- } else if (SAMPLER_TYPE_HTTP_SAMPLER_HC4.equals(type)){ >- type = HTTPSamplerFactory.IMPL_HTTP_CLIENT4; >+ switch(type) { >+ case SAMPLER_TYPE_HTTP_SAMPLER_HC3_1: >+ case SAMPLER_TYPE_HTTP_SAMPLER_HC4: >+ type = HTTPSamplerFactory.IMPL_HTTP_CLIENT4; >+ break; >+ case SAMPLER_TYPE_HTTP_SAMPLER_JAVA: >+ type = HTTPSamplerFactory.IMPL_JAVA; >+ break; >+ default: >+ throw new IllegalArgumentException("Unknown sampler type:"+type); > } > return type; > } >Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java (revision 1782633) >+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java (nonexistent) >@@ -1,1137 +0,0 @@ >-/* >- * 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. >- */ >-package org.apache.jmeter.protocol.http.sampler; >- >-import java.io.ByteArrayOutputStream; >-import java.io.File; >-import java.io.FileNotFoundException; >-import java.io.IOException; >-import java.io.InputStream; >-import java.io.OutputStream; >-import java.net.InetAddress; >-import java.net.URL; >-import java.net.URLDecoder; >-import java.util.ArrayList; >-import java.util.HashMap; >-import java.util.List; >-import java.util.Map; >-import java.util.zip.GZIPInputStream; >- >-import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler; >-import org.apache.commons.httpclient.Header; >-import org.apache.commons.httpclient.HostConfiguration; >-import org.apache.commons.httpclient.HttpClient; >-import org.apache.commons.httpclient.HttpConnectionManager; >-import org.apache.commons.httpclient.HttpMethod; >-import org.apache.commons.httpclient.HttpMethodBase; >-import org.apache.commons.httpclient.HttpState; >-import org.apache.commons.httpclient.HttpVersion; >-import org.apache.commons.httpclient.NTCredentials; >-import org.apache.commons.httpclient.ProtocolException; >-import org.apache.commons.httpclient.SimpleHttpConnectionManager; >-import org.apache.commons.httpclient.auth.AuthScope; >-import org.apache.commons.httpclient.cookie.CookiePolicy; >-import org.apache.commons.httpclient.methods.EntityEnclosingMethod; >-import org.apache.commons.httpclient.methods.FileRequestEntity; >-import org.apache.commons.httpclient.methods.GetMethod; >-import org.apache.commons.httpclient.methods.HeadMethod; >-import org.apache.commons.httpclient.methods.OptionsMethod; >-import org.apache.commons.httpclient.methods.PostMethod; >-import org.apache.commons.httpclient.methods.PutMethod; >-import org.apache.commons.httpclient.methods.StringRequestEntity; >-import org.apache.commons.httpclient.methods.TraceMethod; >-import org.apache.commons.httpclient.methods.multipart.FilePart; >-import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity; >-import org.apache.commons.httpclient.methods.multipart.Part; >-import org.apache.commons.httpclient.methods.multipart.PartBase; >-import org.apache.commons.httpclient.methods.multipart.StringPart; >-import org.apache.commons.httpclient.params.DefaultHttpParams; >-import org.apache.commons.httpclient.params.HttpClientParams; >-import org.apache.commons.httpclient.params.HttpMethodParams; >-import org.apache.commons.httpclient.params.HttpParams; >-import org.apache.commons.httpclient.protocol.Protocol; >-import org.apache.commons.io.input.CountingInputStream; >-import org.apache.jmeter.protocol.http.control.AuthManager; >-import org.apache.jmeter.protocol.http.control.Authorization; >-import org.apache.jmeter.protocol.http.control.CacheManager; >-import org.apache.jmeter.protocol.http.control.CookieManager; >-import org.apache.jmeter.protocol.http.control.HeaderManager; >-import org.apache.jmeter.protocol.http.util.EncoderCache; >-import org.apache.jmeter.protocol.http.util.HTTPArgument; >-import org.apache.jmeter.protocol.http.util.HTTPConstants; >-import org.apache.jmeter.protocol.http.util.HTTPFileArg; >-import org.apache.jmeter.protocol.http.util.LoopbackHttpClientSocketFactory; >-import org.apache.jmeter.protocol.http.util.SlowHttpClientSocketFactory; >-import org.apache.jmeter.services.FileServer; >-import org.apache.jmeter.testelement.property.CollectionProperty; >-import org.apache.jmeter.testelement.property.JMeterProperty; >-import org.apache.jmeter.util.JMeterUtils; >-import org.apache.jmeter.util.JsseSSLManager; >-import org.apache.jmeter.util.SSLManager; >-import org.apache.jorphan.util.JOrphanUtils; >-import org.slf4j.Logger; >-import org.slf4j.LoggerFactory; >- >-/** >- * HTTP sampler using Apache (Jakarta) Commons HttpClient 3.1. >- * @deprecated since 3.0, will be removed in next version >- */ >-@Deprecated >-public class HTTPHC3Impl extends HTTPHCAbstractImpl { >- >- private static final Logger log = LoggerFactory.getLogger(HTTPHC3Impl.class); >- >- /** retry count to be used (default 1); 0 = disable retries */ >- private static final int RETRY_COUNT = JMeterUtils.getPropDefault("httpclient3.retrycount", 0); >- >- private static final String HTTP_AUTHENTICATION_PREEMPTIVE = "http.authentication.preemptive"; // $NON-NLS-1$ >- >- private static final boolean CAN_SET_PREEMPTIVE; // OK to set pre-emptive auth? >- >- private static final ThreadLocal<Map<HostConfiguration, HttpClient>> httpClients = >- ThreadLocal.withInitial(HashMap::new); >- >- // Needs to be accessible by HTTPSampler2 >- volatile HttpClient savedClient; >- >- private volatile boolean resetSSLContext; >- >- static { >- log.info("HTTP request retry count = "+RETRY_COUNT); >- if (CPS_HTTP > 0) { >- log.info("Setting up HTTP SlowProtocol, cps="+CPS_HTTP); >- Protocol.registerProtocol(HTTPConstants.PROTOCOL_HTTP, >- new Protocol(HTTPConstants.PROTOCOL_HTTP,new SlowHttpClientSocketFactory(CPS_HTTP),HTTPConstants.DEFAULT_HTTP_PORT)); >- } >- >- // Now done in JsseSSLManager (which needs to register the protocol) >-// cps = >-// JMeterUtils.getPropDefault("httpclient.socket.https.cps", 0); // $NON-NLS-1$ >-// >-// if (cps > 0) { >-// log.info("Setting up HTTPS SlowProtocol, cps="+cps); >-// Protocol.registerProtocol(PROTOCOL_HTTPS, >-// new Protocol(PROTOCOL_HTTPS,new SlowHttpClientSocketFactory(cps),DEFAULT_HTTPS_PORT)); >-// } >- >- // Set default parameters as needed >- HttpParams params = DefaultHttpParams.getDefaultParams(); >- params.setIntParameter("http.protocol.max-redirects", HTTPSamplerBase.MAX_REDIRECTS); //$NON-NLS-1$ >- // Process Commons HttpClient parameters file >- String file=JMeterUtils.getProperty("httpclient.parameters.file"); // $NON-NLS-1$ >- if (file != null) { >- HttpClientDefaultParameters.load(file, params); >- } >- >- // If the pre-emptive parameter is undefined, then we can set it as needed >- // otherwise we should do what the user requested. >- CAN_SET_PREEMPTIVE = params.getParameter(HTTP_AUTHENTICATION_PREEMPTIVE) == null; >- >- // Handle old-style JMeter properties >- try { >- params.setParameter(HttpMethodParams.PROTOCOL_VERSION, HttpVersion.parse("HTTP/"+HTTP_VERSION)); >- } catch (ProtocolException e) { >- log.warn("Problem setting protocol version "+e.getLocalizedMessage()); >- } >- >- if (SO_TIMEOUT >= 0){ >- params.setIntParameter(HttpMethodParams.SO_TIMEOUT, SO_TIMEOUT); >- } >- >- // This must be done last, as must not be overridden >- params.setParameter(HttpMethodParams.COOKIE_POLICY,CookiePolicy.IGNORE_COOKIES); >- // We do our own cookie handling >- >- if (USE_LOOPBACK){ >- LoopbackHttpClientSocketFactory.setup(); >- } >- } >- >- protected HTTPHC3Impl(HTTPSamplerBase base) { >- super(base); >- } >- >- >- /** >- * Samples the URL passed in and stores the result in >- * <code>HTTPSampleResult</code>, following redirects and downloading >- * page resources as appropriate. >- * <p> >- * When getting a redirect target, redirects are not followed and resources >- * are not downloaded. The caller will take care of this. >- * >- * @param url >- * URL to sample >- * @param method >- * HTTP method: GET, POST,... >- * @param areFollowingRedirect >- * whether we're getting a redirect target >- * @param frameDepth >- * Depth of this target in the frame structure. Used only to >- * prevent infinite recursion. >- * @return results of the sampling >- */ >- @Override >- protected HTTPSampleResult sample(URL url, String method, boolean areFollowingRedirect, int frameDepth) { >- >- String urlStr = url.toString(); >- >- if (log.isDebugEnabled()) { >- log.debug("Start : sample " + urlStr); >- log.debug("method " + method+ " followingRedirect " + areFollowingRedirect + " depth " + frameDepth); >- } >- >- HttpMethodBase httpMethod = null; >- >- HTTPSampleResult res = new HTTPSampleResult(); >- >- res.setSampleLabel(urlStr); // May be replaced later >- res.setHTTPMethod(method); >- res.setURL(url); >- >- res.sampleStart(); // Count the retries as well in the time >- try { >- // May generate IllegalArgumentException >- if (method.equals(HTTPConstants.POST)) { >- httpMethod = new PostMethod(urlStr); >- } else if (method.equals(HTTPConstants.GET)){ >- httpMethod = new GetMethod(urlStr); >- } else if (method.equals(HTTPConstants.PUT)){ >- httpMethod = new PutMethod(urlStr); >- } else if (method.equals(HTTPConstants.HEAD)){ >- httpMethod = new HeadMethod(urlStr); >- } else if (method.equals(HTTPConstants.TRACE)){ >- httpMethod = new TraceMethod(urlStr); >- } else if (method.equals(HTTPConstants.OPTIONS)){ >- httpMethod = new OptionsMethod(urlStr); >- } else if (method.equals(HTTPConstants.DELETE)){ >- httpMethod = new EntityEnclosingMethod(urlStr) { >- @Override >- public String getName() { // HC3.1 does not have the method >- return HTTPConstants.DELETE; >- } >- }; >- } else if (method.equals(HTTPConstants.PATCH)){ >- httpMethod = new EntityEnclosingMethod(urlStr) { >- @Override >- public String getName() { // HC3.1 does not have the method >- return HTTPConstants.PATCH; >- } >- }; >- } else { >- throw new IllegalArgumentException("Unexpected method: '"+method+"'"); >- } >- >- final CacheManager cacheManager = getCacheManager(); >- if (cacheManager != null && HTTPConstants.GET.equalsIgnoreCase(method)) { >- if (cacheManager.inCache(url)) { >- return updateSampleResultForResourceInCache(res); >- } >- } >- >- // Set any default request headers >- setDefaultRequestHeaders(httpMethod); >- >- // Setup connection >- HttpClient client = setupConnection(url, httpMethod, res); >- savedClient = client; >- >- // Handle the various methods >- if (method.equals(HTTPConstants.POST)) { >- String postBody = sendPostData((PostMethod)httpMethod); >- res.setQueryString(postBody); >- } else if (method.equals(HTTPConstants.PUT) || method.equals(HTTPConstants.PATCH) >- || method.equals(HTTPConstants.DELETE)) { >- String putBody = sendEntityData((EntityEnclosingMethod) httpMethod); >- res.setQueryString(putBody); >- } >- >- int statusCode = client.executeMethod(httpMethod); >- >- // We've finished with the request, so we can add the LocalAddress to it for display >- final InetAddress localAddr = client.getHostConfiguration().getLocalAddress(); >- if (localAddr != null) { >- httpMethod.addRequestHeader(HEADER_LOCAL_ADDRESS, localAddr.toString()); >- } >- // Needs to be done after execute to pick up all the headers >- res.setRequestHeaders(getConnectionHeaders(httpMethod)); >- >- // Request sent. Now get the response: >- InputStream instream = httpMethod.getResponseBodyAsStream(); >- >- if (instream != null) {// will be null for HEAD >- instream = new CountingInputStream(instream); >- try { >- Header responseHeader = httpMethod.getResponseHeader(HTTPConstants.HEADER_CONTENT_ENCODING); >- if (responseHeader!= null && HTTPConstants.ENCODING_GZIP.equals(responseHeader.getValue())) { >- InputStream tmpInput = new GZIPInputStream(instream); // tmp inputstream needs to have a good counting >- res.setResponseData(readResponse(res, tmpInput, httpMethod.getResponseContentLength())); >- } else { >- res.setResponseData(readResponse(res, instream, httpMethod.getResponseContentLength())); >- } >- } finally { >- JOrphanUtils.closeQuietly(instream); >- } >- } >- >- res.sampleEnd(); >- // Done with the sampling proper. >- >- // Now collect the results into the HTTPSampleResult: >- >- res.setSampleLabel(httpMethod.getURI().toString()); >- // Pick up Actual path (after redirects) >- >- res.setResponseCode(Integer.toString(statusCode)); >- res.setSuccessful(isSuccessCode(statusCode)); >- >- res.setResponseMessage(httpMethod.getStatusText()); >- >- String ct = null; >- Header h = httpMethod.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE); >- if (h != null)// Can be missing, e.g. on redirect >- { >- ct = h.getValue(); >- res.setContentType(ct);// e.g. text/html; charset=ISO-8859-1 >- res.setEncodingAndType(ct); >- } >- >- res.setResponseHeaders(getResponseHeaders(httpMethod)); >- if (res.isRedirect()) { >- final Header headerLocation = httpMethod.getResponseHeader(HTTPConstants.HEADER_LOCATION); >- if (headerLocation == null) { // HTTP protocol violation, but avoids NPE >- throw new IllegalArgumentException("Missing location header"); >- } >- String redirectLocation = headerLocation.getValue(); >- res.setRedirectLocation(redirectLocation); // in case sanitising fails >- } >- >- // record some sizes to allow HTTPSampleResult.getBytes() with different options >- if (instream != null) { >- res.setBodySize(((CountingInputStream) instream).getByteCount()); >- } >- res.setHeadersSize(calculateHeadersSize(httpMethod)); >- if (log.isDebugEnabled()) { >- log.debug("Response headersSize=" + res.getHeadersSize() + " bodySize=" + res.getBodySizeAsLong() >- + " Total=" + (res.getHeadersSize() + res.getBodySizeAsLong())); >- } >- >- // If we redirected automatically, the URL may have changed >- if (getAutoRedirects()){ >- res.setURL(new URL(httpMethod.getURI().toString())); >- } >- >- // Store any cookies received in the cookie manager: >- saveConnectionCookies(httpMethod, res.getURL(), getCookieManager()); >- >- // Save cache information >- if (cacheManager != null){ >- cacheManager.saveDetails(httpMethod, res); >- } >- >- // Follow redirects and download page resources if appropriate: >- res = resultProcessing(areFollowingRedirect, frameDepth, res); >- >- log.debug("End : sample"); >- return res; >- } catch (IllegalArgumentException // e.g. some kinds of invalid URL >- | IOException e) { >- res.sampleEnd(); >- // pick up headers if failed to execute the request >- // httpMethod can be null if method is unexpected >- if(httpMethod != null) { >- res.setRequestHeaders(getConnectionHeaders(httpMethod)); >- } >- errorResult(e, res); >- return res; >- } finally { >- savedClient = null; >- if (httpMethod != null) { >- httpMethod.releaseConnection(); >- } >- } >- } >- >- /** >- * Calculate response headers size >- * >- * @return the size response headers (in bytes) >- */ >- private static int calculateHeadersSize(HttpMethodBase httpMethod) { >- int headerSize = httpMethod.getStatusLine().toString().length()+2; // add a \r\n >- Header[] rh = httpMethod.getResponseHeaders(); >- for (Header responseHeader : rh) { >- headerSize += responseHeader.toString().length(); // already include the \r\n >- } >- headerSize += 2; // last \r\n before response data >- return headerSize; >- } >- >- /** >- * Returns an <code>HttpConnection</code> fully ready to attempt >- * connection. This means it sets the request method (GET or POST), headers, >- * cookies, and authorization for the URL request. >- * <p> >- * The request infos are saved into the sample result if one is provided. >- * >- * @param u >- * <code>URL</code> of the URL request >- * @param httpMethod >- * GET/PUT/HEAD etc >- * @param res >- * sample result to save request infos to >- * @return <code>HttpConnection</code> ready for .connect >- * @exception IOException >- * if an I/O Exception occurs >- */ >- protected HttpClient setupConnection(URL u, HttpMethodBase httpMethod, HTTPSampleResult res) throws IOException { >- >- String urlStr = u.toString(); >- >- org.apache.commons.httpclient.URI uri = new org.apache.commons.httpclient.URI(urlStr,false); >- >- String schema = uri.getScheme(); >- if ((schema == null) || (schema.length()==0)) { >- schema = HTTPConstants.PROTOCOL_HTTP; >- } >- >- final boolean isHTTPS = HTTPConstants.PROTOCOL_HTTPS.equalsIgnoreCase(schema); >- if (isHTTPS){ >- SSLManager.getInstance(); // ensure the manager is initialised >- // we don't currently need to do anything further, as this sets the default https protocol >- } >- >- Protocol protocol = Protocol.getProtocol(schema); >- >- String host = uri.getHost(); >- int port = uri.getPort(); >- >- /* >- * We use the HostConfiguration as the key to retrieve the HttpClient, >- * so need to ensure that any items used in its equals/hashcode methods are >- * not changed after use, i.e.: >- * host, port, protocol, localAddress, proxy >- * >- */ >- HostConfiguration hc = new HostConfiguration(); >- hc.setHost(host, port, protocol); // All needed to ensure re-usablility >- >- // Set up the local address if one exists >- final InetAddress inetAddr = getIpSourceAddress(); >- if (inetAddr != null) {// Use special field ip source address (for pseudo 'ip spoofing') >- hc.setLocalAddress(inetAddr); >- } else { >- hc.setLocalAddress(localAddress); // null means use the default >- } >- >- final String proxyHost = getProxyHost(); >- final int proxyPort = getProxyPortInt(); >- >- boolean useStaticProxy = isStaticProxy(host); >- boolean useDynamicProxy = isDynamicProxy(proxyHost, proxyPort); >- >- if (useDynamicProxy){ >- hc.setProxy(proxyHost, proxyPort); >- useStaticProxy = false; // Dynamic proxy overrules static proxy >- } else if (useStaticProxy) { >- if (log.isDebugEnabled()){ >- log.debug("Setting proxy: "+PROXY_HOST+":"+PROXY_PORT); >- } >- hc.setProxy(PROXY_HOST, PROXY_PORT); >- } >- >- Map<HostConfiguration, HttpClient> map = httpClients.get(); >- // N.B. HostConfiguration.equals() includes proxy settings in the compare. >- HttpClient httpClient = map.get(hc); >- >- if (httpClient != null && resetSSLContext && isHTTPS) { >- httpClient.getHttpConnectionManager().closeIdleConnections(-1000); >- httpClient = null; >- JsseSSLManager sslMgr = (JsseSSLManager) SSLManager.getInstance(); >- sslMgr.resetContext(); >- resetSSLContext = false; >- } >- >- if ( httpClient == null ) >- { >- httpClient = new HttpClient(new SimpleHttpConnectionManager()); >- httpClient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, >- new DefaultHttpMethodRetryHandler(RETRY_COUNT, false)); >- if (log.isDebugEnabled()) { >- log.debug("Created new HttpClient: @"+System.identityHashCode(httpClient)); >- } >- httpClient.setHostConfiguration(hc); >- map.put(hc, httpClient); >- } else { >- if (log.isDebugEnabled()) { >- log.debug("Reusing the HttpClient: @"+System.identityHashCode(httpClient)); >- } >- } >- >- // Set up any required Proxy credentials >- if (useDynamicProxy){ >- String user = getProxyUser(); >- if (user.length() > 0){ >- httpClient.getState().setProxyCredentials( >- new AuthScope(proxyHost,proxyPort,null,AuthScope.ANY_SCHEME), >- new NTCredentials(user,getProxyPass(),LOCALHOST,PROXY_DOMAIN) >- ); >- } else { >- httpClient.getState().clearProxyCredentials(); >- } >- } else { >- if (useStaticProxy) { >- if (PROXY_USER.length() > 0){ >- httpClient.getState().setProxyCredentials( >- new AuthScope(PROXY_HOST,PROXY_PORT,null,AuthScope.ANY_SCHEME), >- new NTCredentials(PROXY_USER,PROXY_PASS,LOCALHOST,PROXY_DOMAIN) >- ); >- } >- } else { >- httpClient.getState().clearProxyCredentials(); >- } >- } >- >- int rto = getResponseTimeout(); >- if (rto > 0){ >- httpMethod.getParams().setSoTimeout(rto); >- } >- >- int cto = getConnectTimeout(); >- if (cto > 0){ >- httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(cto); >- } >- >- >- // Allow HttpClient to handle the redirects: >- httpMethod.setFollowRedirects(getAutoRedirects()); >- >- // a well-behaved browser is supposed to send 'Connection: close' >- // with the last request to an HTTP server. Instead, most browsers >- // leave it to the server to close the connection after their >- // timeout period. Leave it to the JMeter user to decide. >- if (getUseKeepAlive()) { >- httpMethod.setRequestHeader(HTTPConstants.HEADER_CONNECTION, HTTPConstants.KEEP_ALIVE); >- } else { >- httpMethod.setRequestHeader(HTTPConstants.HEADER_CONNECTION, HTTPConstants.CONNECTION_CLOSE); >- } >- >- setConnectionHeaders(httpMethod, u, getHeaderManager(), getCacheManager()); >- String cookies = setConnectionCookie(httpMethod, u, getCookieManager()); >- >- setConnectionAuthorization(httpClient, u, getAuthManager()); >- >- if (res != null) { >- res.setCookies(cookies); >- } >- >- return httpClient; >- } >- >- /** >- * Set any default request headers to include >- * >- * @param httpMethod the HttpMethod used for the request >- */ >- protected void setDefaultRequestHeaders(HttpMethod httpMethod) { >- // Method left empty here, but allows subclasses to override >- } >- >- /** >- * Gets the ResponseHeaders >- * >- * @param method the method used to perform the request >- * @return string containing the headers, one per line >- */ >- protected String getResponseHeaders(HttpMethod method) { >- StringBuilder headerBuf = new StringBuilder(); >- org.apache.commons.httpclient.Header[] rh = method.getResponseHeaders(); >- headerBuf.append(method.getStatusLine());// header[0] is not the status line... >- headerBuf.append("\n"); // $NON-NLS-1$ >- >- for (Header responseHeader : rh) { >- String key = responseHeader.getName(); >- headerBuf.append(key); >- headerBuf.append(": "); // $NON-NLS-1$ >- headerBuf.append(responseHeader.getValue()); >- headerBuf.append("\n"); // $NON-NLS-1$ >- } >- return headerBuf.toString(); >- } >- >- /** >- * Extracts all the required cookies for that particular URL request and >- * sets them in the <code>HttpMethod</code> passed in. >- * >- * @param method <code>HttpMethod</code> for the request >- * @param u <code>URL</code> of the request >- * @param cookieManager the <code>CookieManager</code> containing all the cookies >- * @return a String containing the cookie details (for the response) >- * May be null >- */ >- private String setConnectionCookie(HttpMethod method, URL u, CookieManager cookieManager) { >- String cookieHeader = null; >- if (cookieManager != null) { >- cookieHeader = cookieManager.getCookieHeaderForURL(u); >- if (cookieHeader != null) { >- method.setRequestHeader(HTTPConstants.HEADER_COOKIE, cookieHeader); >- } >- } >- return cookieHeader; >- } >- >- /** >- * Extracts all the required non-cookie headers for that particular URL request and >- * sets them in the <code>HttpMethod</code> passed in >- * >- * @param method >- * <code>HttpMethod</code> which represents the request >- * @param u >- * <code>URL</code> of the URL request >- * @param headerManager >- * the <code>HeaderManager</code> containing all the cookies >- * for this <code>UrlConfig</code> >- * @param cacheManager the CacheManager (may be null) >- */ >- private void setConnectionHeaders(HttpMethod method, URL u, HeaderManager headerManager, CacheManager cacheManager) { >- // Set all the headers from the HeaderManager >- if (headerManager != null) { >- CollectionProperty headers = headerManager.getHeaders(); >- if (headers != null) { >- for (JMeterProperty jMeterProperty : headers) { >- org.apache.jmeter.protocol.http.control.Header header >- = (org.apache.jmeter.protocol.http.control.Header) >- jMeterProperty.getObjectValue(); >- String n = header.getName(); >- // Don't allow override of Content-Length >- // This helps with SoapSampler hack too >- // TODO - what other headers are not allowed? >- if (! HTTPConstants.HEADER_CONTENT_LENGTH.equalsIgnoreCase(n)){ >- String v = header.getValue(); >- if (HTTPConstants.HEADER_HOST.equalsIgnoreCase(n)) { >- v = v.replaceFirst(":\\d+$",""); // remove any port specification // $NON-NLS-1$ $NON-NLS-2$ >- method.getParams().setVirtualHost(v); >- } else { >- method.addRequestHeader(n, v); >- } >- } >- } >- } >- } >- if (cacheManager != null){ >- cacheManager.setHeaders(u, method); >- } >- } >- >- /** >- * Get all the request headers for the <code>HttpMethod</code> >- * >- * @param method >- * <code>HttpMethod</code> which represents the request >- * @return the headers as a string >- */ >- protected String getConnectionHeaders(HttpMethod method) { >- // Get all the request headers >- StringBuilder hdrs = new StringBuilder(100); >- Header[] requestHeaders = method.getRequestHeaders(); >- for (Header requestHeader : requestHeaders) { >- // Exclude the COOKIE header, since cookie is reported separately in the sample >- if (!HTTPConstants.HEADER_COOKIE.equalsIgnoreCase(requestHeader.getName())) { >- hdrs.append(requestHeader.getName()); >- hdrs.append(": "); // $NON-NLS-1$ >- hdrs.append(requestHeader.getValue()); >- hdrs.append("\n"); // $NON-NLS-1$ >- } >- } >- >- return hdrs.toString(); >- } >- >- >- /** >- * Extracts all the required authorization for that particular URL request >- * and sets it in the <code>HttpMethod</code> passed in. >- * >- * @param client the HttpClient object >- * >- * @param u >- * <code>URL</code> of the URL request >- * @param authManager >- * the <code>AuthManager</code> containing all the authorisations for >- * this <code>UrlConfig</code> >- */ >- private void setConnectionAuthorization(HttpClient client, URL u, AuthManager authManager) { >- HttpState state = client.getState(); >- if (authManager != null) { >- HttpClientParams params = client.getParams(); >- Authorization auth = authManager.getAuthForURL(u); >- if (auth != null) { >- String username = auth.getUser(); >- String realm = auth.getRealm(); >- String domain = auth.getDomain(); >- if (log.isDebugEnabled()){ >- log.debug(username + " > D="+ username + " D="+domain+" R="+realm); >- } >- state.setCredentials( >- new AuthScope(u.getHost(),u.getPort(), >- realm.length()==0 ? null : realm //"" is not the same as no realm >- ,AuthScope.ANY_SCHEME), >- // NT Includes other types of Credentials >- new NTCredentials( >- username, >- auth.getPass(), >- LOCALHOST, >- domain >- )); >- // We have credentials - should we set pre-emptive authentication? >- if (CAN_SET_PREEMPTIVE){ >- log.debug("Setting Pre-emptive authentication"); >- params.setAuthenticationPreemptive(true); >- } >- } else { >- state.clearCredentials(); >- if (CAN_SET_PREEMPTIVE){ >- params.setAuthenticationPreemptive(false); >- } >- } >- } else { >- state.clearCredentials(); >- } >- } >- >- >- /* >- * Send POST data from <code>Entry</code> to the open connection. >- * >- * @param connection >- * <code>URLConnection</code> where POST data should be sent >- * @return a String show what was posted. Will not contain actual file upload content >- * @exception IOException >- * if an I/O exception occurs >- */ >- private String sendPostData(PostMethod post) throws IOException { >- // Buffer to hold the post body, except file content >- StringBuilder postedBody = new StringBuilder(1000); >- HTTPFileArg[] files = getHTTPFiles(); >- // Check if we should do a multipart/form-data or an >- // application/x-www-form-urlencoded post request >- if(getUseMultipartForPost()) { >- // If a content encoding is specified, we use that as the >- // encoding of any parameter values >- String contentEncoding = getContentEncoding(); >- if(isNullOrEmptyTrimmed(contentEncoding)) { >- contentEncoding = null; >- } >- >- final boolean browserCompatible = getDoBrowserCompatibleMultipart(); >- // We don't know how many entries will be skipped >- List<PartBase> partlist = new ArrayList<>(); >- // Create the parts >- // Add any parameters >- for (JMeterProperty jMeterProperty : getArguments()) { >- HTTPArgument arg = (HTTPArgument) jMeterProperty.getObjectValue(); >- String parameterName = arg.getName(); >- if (arg.isSkippable(parameterName)) { >- continue; >- } >- StringPart part = new StringPart(arg.getName(), arg.getValue(), contentEncoding); >- if (browserCompatible) { >- part.setTransferEncoding(null); >- part.setContentType(null); >- } >- partlist.add(part); >- } >- >- // Add any files >- for (HTTPFileArg file : files) { >- File inputFile = FileServer.getFileServer().getResolvedFile(file.getPath()); >- // We do not know the char set of the file to be uploaded, so we set it to null >- ViewableFilePart filePart = new ViewableFilePart(file.getParamName(), inputFile, file.getMimeType(), null); >- filePart.setCharSet(null); // We do not know what the char set of the file is >- partlist.add(filePart); >- } >- >- // Set the multipart for the post >- int partNo = partlist.size(); >- Part[] parts = partlist.toArray(new Part[partNo]); >- MultipartRequestEntity multiPart = new MultipartRequestEntity(parts, post.getParams()); >- post.setRequestEntity(multiPart); >- >- // Set the content type >- String multiPartContentType = multiPart.getContentType(); >- post.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE, multiPartContentType); >- >- // If the Multipart is repeatable, we can send it first to >- // our own stream, without the actual file content, so we can return it >- if(multiPart.isRepeatable()) { >- // For all the file multiparts, we must tell it to not include >- // the actual file content >- for(int i = 0; i < partNo; i++) { >- if(parts[i] instanceof ViewableFilePart) { >- ((ViewableFilePart) parts[i]).setHideFileData(true); // .sendMultipartWithoutFileContent(bos); >- } >- } >- // Write the request to our own stream >- ByteArrayOutputStream bos = new ByteArrayOutputStream(); >- multiPart.writeRequest(bos); >- bos.flush(); >- // We get the posted bytes using the encoding used to create it >- postedBody.append(new String(bos.toByteArray(), >- contentEncoding == null ? "US-ASCII" // $NON-NLS-1$ this is the default used by HttpClient >- : contentEncoding)); >- bos.close(); >- >- // For all the file multiparts, we must revert the hiding of >- // the actual file content >- for(int i = 0; i < partNo; i++) { >- if(parts[i] instanceof ViewableFilePart) { >- ((ViewableFilePart) parts[i]).setHideFileData(false); >- } >- } >- } >- else { >- postedBody.append("<Multipart was not repeatable, cannot view what was sent>"); // $NON-NLS-1$ >- } >- } >- else { >- // Check if the header manager had a content type header >- // This allows the user to specify his own content-type for a POST request >- Header contentTypeHeader = post.getRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE); >- boolean hasContentTypeHeader = contentTypeHeader != null && contentTypeHeader.getValue() != null && contentTypeHeader.getValue().length() > 0; >- // If there are no arguments, we can send a file as the body of the request >- // TODO: needs a multiple file upload scenerio >- if(!hasArguments() && getSendFileAsPostBody()) { >- // If getSendFileAsPostBody returned true, it's sure that file is not null >- HTTPFileArg file = files[0]; >- if(!hasContentTypeHeader) { >- // Allow the mimetype of the file to control the content type >- if(file.getMimeType() != null && file.getMimeType().length() > 0) { >- post.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE, file.getMimeType()); >- } >- else { >- post.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE, HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED); >- } >- } >- >- FileRequestEntity fileRequestEntity = new FileRequestEntity(new File(file.getPath()),null); >- post.setRequestEntity(fileRequestEntity); >- >- // We just add placeholder text for file content >- postedBody.append("<actual file content, not shown here>"); >- } >- else { >- // In a post request which is not multipart, we only support >- // parameters, no file upload is allowed >- >- // If a content encoding is specified, we set it as http parameter, so that >- // the post body will be encoded in the specified content encoding >- String contentEncoding = getContentEncoding(); >- boolean haveContentEncoding = false; >- if(isNullOrEmptyTrimmed(contentEncoding)) { >- contentEncoding=null; >- } else { >- post.getParams().setContentCharset(contentEncoding); >- haveContentEncoding = true; >- } >- >- // If none of the arguments have a name specified, we >- // just send all the values as the post body >- if(getSendParameterValuesAsPostBody()) { >- // Allow the mimetype of the file to control the content type >- // This is not obvious in GUI if you are not uploading any files, >- // but just sending the content of nameless parameters >- // TODO: needs a multiple file upload scenerio >- if(!hasContentTypeHeader) { >- HTTPFileArg file = files.length > 0? files[0] : null; >- if(file != null && file.getMimeType() != null && file.getMimeType().length() > 0) { >- post.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE, file.getMimeType()); >- } >- else { >- // TODO - is this the correct default? >- post.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE, HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED); >- } >- } >- >- // Just append all the parameter values, and use that as the post body >- StringBuilder postBody = new StringBuilder(); >- for (JMeterProperty jMeterProperty : getArguments()) { >- HTTPArgument arg = (HTTPArgument) jMeterProperty.getObjectValue(); >- String value; >- if (haveContentEncoding) { >- value = arg.getEncodedValue(contentEncoding); >- } else { >- value = arg.getEncodedValue(); >- } >- postBody.append(value); >- } >- StringRequestEntity requestEntity = new StringRequestEntity(postBody.toString(), post.getRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE).getValue(), contentEncoding); >- post.setRequestEntity(requestEntity); >- } >- else { >- // It is a normal post request, with parameter names and values >- >- // Set the content type >- if(!hasContentTypeHeader) { >- post.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE, HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED); >- } >- // Add the parameters >- for (JMeterProperty jMeterProperty : getArguments()) { >- HTTPArgument arg = (HTTPArgument) jMeterProperty.getObjectValue(); >- // The HTTPClient always urlencodes both name and value, >- // so if the argument is already encoded, we have to decode >- // it before adding it to the post request >- String parameterName = arg.getName(); >- if (arg.isSkippable(parameterName)) { >- continue; >- } >- String parameterValue = arg.getValue(); >- if (!arg.isAlwaysEncoded()) { >- // The value is already encoded by the user >- // Must decode the value now, so that when the >- // httpclient encodes it, we end up with the same value >- // as the user had entered. >- String urlContentEncoding = contentEncoding; >- if (urlContentEncoding == null || urlContentEncoding.length() == 0) { >- // Use the default encoding for urls >- urlContentEncoding = EncoderCache.URL_ARGUMENT_ENCODING; >- } >- parameterName = URLDecoder.decode(parameterName, urlContentEncoding); >- parameterValue = URLDecoder.decode(parameterValue, urlContentEncoding); >- } >- // Add the parameter, httpclient will urlencode it >- post.addParameter(parameterName, parameterValue); >- } >- >-/* >-// // Alternative implementation, to make sure that HTTPSampler and HTTPSampler2 >-// // sends the same post body. >-// >-// // Only include the content char set in the content-type header if it is not >-// // an APPLICATION_X_WWW_FORM_URLENCODED content type >-// String contentCharSet = null; >-// if(!post.getRequestHeader(HEADER_CONTENT_TYPE).getValue().equals(APPLICATION_X_WWW_FORM_URLENCODED)) { >-// contentCharSet = post.getRequestCharSet(); >-// } >-// StringRequestEntity requestEntity = new StringRequestEntity(getQueryString(contentEncoding), post.getRequestHeader(HEADER_CONTENT_TYPE).getValue(), contentCharSet); >-// post.setRequestEntity(requestEntity); >-*/ >- } >- >- // If the request entity is repeatable, we can send it first to >- // our own stream, so we can return it >- if(post.getRequestEntity().isRepeatable()) { >- ByteArrayOutputStream bos = new ByteArrayOutputStream(); >- post.getRequestEntity().writeRequest(bos); >- bos.flush(); >- // We get the posted bytes using the encoding used to create it >- postedBody.append(new String(bos.toByteArray(),post.getRequestCharSet())); >- bos.close(); >- } >- else { >- postedBody.append("<RequestEntity was not repeatable, cannot view what was sent>"); >- } >- } >- } >- // Set the content length >- post.setRequestHeader(HTTPConstants.HEADER_CONTENT_LENGTH, Long.toString(post.getRequestEntity().getContentLength())); >- >- return postedBody.toString(); >- } >- >- /** >- * Set up the PUT/PATCH/DELETE data >- */ >- private String sendEntityData(EntityEnclosingMethod put) throws IOException { >- // Buffer to hold the put body, except file content >- StringBuilder putBody = new StringBuilder(1000); >- boolean hasPutBody = false; >- >- // Check if the header manager had a content type header >- // This allows the user to specify his own content-type for a POST request >- Header contentTypeHeader = put.getRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE); >- boolean hasContentTypeHeader = contentTypeHeader != null && contentTypeHeader.getValue() != null && contentTypeHeader.getValue().length() > 0; >- HTTPFileArg[] files = getHTTPFiles(); >- >- // If there are no arguments, we can send a file as the body of the request >- >- if(!hasArguments() && getSendFileAsPostBody()) { >- hasPutBody = true; >- >- // If getSendFileAsPostBody returned true, it's sure that file is not null >- File reservedFile = FileServer.getFileServer().getResolvedFile(files[0].getPath()); >- FileRequestEntity fileRequestEntity = new FileRequestEntity(reservedFile,null); >- put.setRequestEntity(fileRequestEntity); >- } >- // If none of the arguments have a name specified, we >- // just send all the values as the put body >- else if(getSendParameterValuesAsPostBody()) { >- hasPutBody = true; >- >- // If a content encoding is specified, we set it as http parameter, so that >- // the post body will be encoded in the specified content encoding >- String contentEncoding = getContentEncoding(); >- boolean haveContentEncoding = false; >- if(isNullOrEmptyTrimmed(contentEncoding)) { >- contentEncoding = null; >- } else { >- put.getParams().setContentCharset(contentEncoding); >- haveContentEncoding = true; >- } >- >- // Just append all the parameter values, and use that as the post body >- StringBuilder putBodyContent = new StringBuilder(); >- for (JMeterProperty jMeterProperty : getArguments()) { >- HTTPArgument arg = (HTTPArgument) jMeterProperty.getObjectValue(); >- String value = null; >- if (haveContentEncoding) { >- value = arg.getEncodedValue(contentEncoding); >- } else { >- value = arg.getEncodedValue(); >- } >- putBodyContent.append(value); >- } >- String contentTypeValue = null; >- if(hasContentTypeHeader) { >- contentTypeValue = put.getRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE).getValue(); >- } >- StringRequestEntity requestEntity = new StringRequestEntity(putBodyContent.toString(), contentTypeValue, put.getRequestCharSet()); >- put.setRequestEntity(requestEntity); >- } >- // Check if we have any content to send for body >- if(hasPutBody) { >- // If the request entity is repeatable, we can send it first to >- // our own stream, so we can return it >- if(put.getRequestEntity().isRepeatable()) { >- putBody.append("<actual file content, not shown here>"); >- } >- else { >- putBody.append("<RequestEntity was not repeatable, cannot view what was sent>"); >- } >- if(!hasContentTypeHeader) { >- // Allow the mimetype of the file to control the content type >- // This is not obvious in GUI if you are not uploading any files, >- // but just sending the content of nameless parameters >- // TODO: needs a multiple file upload scenerio >- HTTPFileArg file = files.length > 0? files[0] : null; >- if(file != null && file.getMimeType() != null && file.getMimeType().length() > 0) { >- put.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE, file.getMimeType()); >- } >- } >- // Set the content length >- put.setRequestHeader(HTTPConstants.HEADER_CONTENT_LENGTH, Long.toString(put.getRequestEntity().getContentLength())); >- } >- return putBody.toString(); >- } >- >- /** >- * Class extending FilePart, so that we can send placeholder text >- * instead of the actual file content >- */ >- private static class ViewableFilePart extends FilePart { >- private boolean hideFileData; >- >- public ViewableFilePart(String name, File file, String contentType, String charset) throws FileNotFoundException { >- super(name, file, contentType, charset); >- this.hideFileData = false; >- } >- >- public void setHideFileData(boolean hideFileData) { >- this.hideFileData = hideFileData; >- } >- >- @Override >- protected void sendData(OutputStream out) throws IOException { >- // Check if we should send only placeholder text for the >- // file content, or the real file content >- if(hideFileData) { >- out.write("<actual file content, not shown here>".getBytes());// encoding does not really matter here >- } >- else { >- super.sendData(out); >- } >- } >- } >- >- /** >- * From the <code>HttpMethod</code>, store all the "set-cookie" key-pair >- * values in the cookieManager of the <code>UrlConfig</code>. >- * >- * @param method >- * <code>HttpMethod</code> which represents the request >- * @param u >- * <code>URL</code> of the URL request >- * @param cookieManager >- * the <code>CookieManager</code> containing all the cookies >- */ >- protected void saveConnectionCookies(HttpMethod method, URL u, CookieManager cookieManager) { >- if (cookieManager != null) { >- Header[] hdr = method.getResponseHeaders(HTTPConstants.HEADER_SET_COOKIE); >- for (Header responseHeader : hdr) { >- cookieManager.addCookieFromHeader(responseHeader.getValue(), u); >- } >- } >- } >- >- >- @Override >- protected void threadFinished() { >- log.debug("Thread Finished"); >- >- closeThreadLocalConnections(); >- } >- >- @Override >- protected void notifyFirstSampleAfterLoopRestart() { >- log.debug("notifyFirstSampleAfterLoopRestart"); >- resetSSLContext = !USE_CACHED_SSL_CONTEXT; >- } >- >- /** >- * >- */ >- private void closeThreadLocalConnections() { >- // Does not need to be synchronised, as all access is from same thread >- Map<HostConfiguration, HttpClient> map = httpClients.get(); >- >- if ( map != null ) { >- for (HttpClient cl : map.values()) >- { >- // Can cause NPE in HttpClient 3.1 >- //((SimpleHttpConnectionManager)cl.getHttpConnectionManager()).shutdown();// Closes the connection >- // Revert to original method: >- cl.getHttpConnectionManager().closeIdleConnections(-1000);// Closes the connection >- } >- map.clear(); >- } >- } >- >- /** {@inheritDoc} */ >- @Override >- public boolean interrupt() { >- HttpClient client = savedClient; >- if (client != null) { >- savedClient = null; >- // TODO - not sure this is the best method >- final HttpConnectionManager httpConnectionManager = client.getHttpConnectionManager(); >- if (httpConnectionManager instanceof SimpleHttpConnectionManager) {// Should be true >- ((SimpleHttpConnectionManager)httpConnectionManager).shutdown(); >- } >- } >- return client != null; >- } >- >-} >Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java (revision 1782633) >+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java (nonexistent) >@@ -1,88 +0,0 @@ >-/* >- * 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. >- */ >-package org.apache.jmeter.protocol.http.sampler; >- >- >-import java.io.IOException; >-import java.net.URL; >- >-import org.apache.commons.httpclient.HttpClient; >-import org.apache.commons.httpclient.HttpMethod; >-import org.apache.commons.httpclient.HttpMethodBase; >-import org.apache.jmeter.engine.event.LoopIterationEvent; >-import org.apache.jmeter.protocol.http.control.CookieManager; >-import org.apache.jmeter.samplers.Interruptible; >- >-/** >- * A sampler which understands all the parts necessary to read statistics about >- * HTTP requests, including cookies and authentication. >- * This sampler uses HttpClient 3.1. >- * @deprecated since 3.0, will be removed in next version >- */ >-@Deprecated >-public class HTTPSampler2 extends HTTPSamplerBase implements Interruptible { >- >- private static final long serialVersionUID = 240L; >- >- private final transient HTTPHC3Impl hc; >- >- public HTTPSampler2(){ >- hc = new HTTPHC3Impl(this); >- } >- >- @Override >- public boolean interrupt() { >- return hc.interrupt(); >- } >- >- @Override >- protected HTTPSampleResult sample(URL u, String method, >- boolean areFollowingRedirect, int depth) { >- return hc.sample(u, method, areFollowingRedirect, depth); >- } >- >- // Methods needed by subclasses to get access to the implementation >- protected HttpClient setupConnection(URL url, HttpMethodBase httpMethod, HTTPSampleResult res) >- throws IOException { >- return hc.setupConnection(url, httpMethod, res); >- } >- >- protected void saveConnectionCookies(HttpMethod httpMethod, URL url, >- CookieManager cookieManager) { >- hc.saveConnectionCookies(httpMethod, url, cookieManager); >- } >- >- protected String getResponseHeaders(HttpMethod httpMethod) { >- return hc.getResponseHeaders(httpMethod); >- } >- >- protected String getConnectionHeaders(HttpMethod httpMethod) { >- return hc.getConnectionHeaders(httpMethod); >- } >- >- protected void setSavedClient(HttpClient savedClient) { >- hc.savedClient = savedClient; >- } >- >- /* (non-Javadoc) >- * @see org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase#testIterationStart(org.apache.jmeter.engine.event.LoopIterationEvent) >- */ >- @Override >- public void testIterationStart(LoopIterationEvent event) { >- hc.notifyFirstSampleAfterLoopRestart(); >- } >-} >Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBaseConverter.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBaseConverter.java (revision 1782633) >+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBaseConverter.java (working copy) >@@ -69,7 +69,7 @@ > httpSampler.setImplementation(HTTPSamplerFactory.IMPL_JAVA); > } > if (nodeName.equals(HTTPSamplerFactory.HTTP_SAMPLER_APACHE)){ >- httpSampler.setImplementation(HTTPSamplerFactory.IMPL_HTTP_CLIENT3_1); >+ httpSampler.setImplementation(HTTPSamplerFactory.IMPL_HTTP_CLIENT4); > } > httpSampler.mergeFileProperties(); > return httpSampler; >Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerFactory.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerFactory.java (revision 1782633) >+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerFactory.java (working copy) >@@ -74,17 +74,14 @@ > if (alias.equals(HTTP_SAMPLER_JAVA) || alias.equals(IMPL_JAVA)) { > return new HTTPSamplerProxy(IMPL_JAVA); > } >- if (alias.equals(HTTP_SAMPLER_APACHE) || alias.equals(IMPL_HTTP_CLIENT3_1)) { >- return new HTTPSamplerProxy(IMPL_HTTP_CLIENT3_1); >- } >- if (alias.equals(IMPL_HTTP_CLIENT4)) { >+ if (alias.equals(IMPL_HTTP_CLIENT4) || alias.equals(HTTP_SAMPLER_APACHE) || alias.equals(IMPL_HTTP_CLIENT3_1)) { > return new HTTPSamplerProxy(IMPL_HTTP_CLIENT4); > } > throw new IllegalArgumentException("Unknown sampler type: '" + alias+"'"); > } > > public static String[] getImplementations(){ >- return new String[]{IMPL_HTTP_CLIENT4,IMPL_HTTP_CLIENT3_1,IMPL_JAVA}; >+ return new String[]{IMPL_HTTP_CLIENT4,IMPL_JAVA}; > } > > public static HTTPAbstractImpl getImplementation(String impl, HTTPSamplerBase base){ >@@ -96,8 +93,6 @@ > } > if (IMPL_JAVA.equals(impl) || HTTP_SAMPLER_JAVA.equals(impl)) { > return new HTTPJavaImpl(base); >- } else if (IMPL_HTTP_CLIENT3_1.equals(impl) || HTTP_SAMPLER_APACHE.equals(impl)) { >- return new HTTPHC3Impl(base); > } else if (IMPL_HTTP_CLIENT4.equals(impl)) { > return new HTTPHC4Impl(base); > } else { >Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpClientDefaultParameters.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpClientDefaultParameters.java (revision 1782633) >+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpClientDefaultParameters.java (working copy) >@@ -27,7 +27,6 @@ > import java.util.Properties; > > import org.apache.jmeter.NewDriver; >-import org.apache.jorphan.util.JOrphanUtils; > import org.slf4j.Logger; > import org.slf4j.LoggerFactory; > >@@ -55,31 +54,6 @@ > * Loads a property file and converts parameters as necessary. > * > * @param file the file to load >- * @param params Commons HttpClient parameter instance >- * @deprecated HC3.1 will be dropped in upcoming version >- */ >- @Deprecated >- public static void load(String file, >- final org.apache.commons.httpclient.params.HttpParams params){ >- load(file, >- new GenericHttpParams (){ >- @Override >- public void setParameter(String name, Object value) { >- params.setParameter(name, value); >- } >- @Override >- public void setVersion(String name, String value) throws Exception { >- params.setParameter(name, >- org.apache.commons.httpclient.HttpVersion.parse("HTTP/"+value)); >- } >- } >- ); >- } >- >- /** >- * Loads a property file and converts parameters as necessary. >- * >- * @param file the file to load > * @param params Apache HttpClient parameter instance > */ > public static void load(String file, >@@ -118,10 +92,8 @@ > } > } > log.info("Reading httpclient parameters from "+f.getAbsolutePath()); >- InputStream is = null; > Properties props = new Properties(); >- try { >- is = new FileInputStream(f); >+ try ( InputStream is = new FileInputStream(f)){ > props.load(is); > for (Map.Entry<Object, Object> me : props.entrySet()){ > String key = (String) me.getKey(); >@@ -153,9 +125,6 @@ > } > } catch (IOException e) { > log.error("Problem loading properties "+e.toString()); >- } finally { >- JOrphanUtils.closeQuietly(is); > } > } >- > } >Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/SoapSampler.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/SoapSampler.java (revision 1782633) >+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/SoapSampler.java (nonexistent) >@@ -1,371 +0,0 @@ >-/* >- * 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. >- * >- */ >- >-package org.apache.jmeter.protocol.http.sampler; >- >-import java.io.BufferedInputStream; >-import java.io.ByteArrayOutputStream; >-import java.io.File; >-import java.io.FileInputStream; >-import java.io.IOException; >-import java.io.InputStream; >-import java.io.OutputStream; >-import java.io.UnsupportedEncodingException; >-import java.net.MalformedURLException; >-import java.net.URL; >-import java.util.zip.GZIPInputStream; >- >-import org.apache.commons.httpclient.HttpClient; >-import org.apache.commons.httpclient.methods.PostMethod; >-import org.apache.commons.httpclient.methods.RequestEntity; >-import org.apache.commons.io.IOUtils; >-import org.apache.jmeter.protocol.http.control.CacheManager; >-import org.apache.jmeter.protocol.http.control.Header; >-import org.apache.jmeter.protocol.http.control.HeaderManager; >-import org.apache.jmeter.protocol.http.util.HTTPConstants; >-import org.apache.jmeter.samplers.Interruptible; >-import org.apache.jmeter.util.JMeterUtils; >-import org.apache.jorphan.util.JOrphanUtils; >-import org.slf4j.Logger; >-import org.slf4j.LoggerFactory; >- >-/** >- * Commons HTTPClient based soap sampler >- * @deprecated since 3.0, will be removed in next version >- */ >-@Deprecated >-public class SoapSampler extends HTTPSampler2 implements Interruptible { // Implemented by parent class >- private static final Logger log = LoggerFactory.getLogger(SoapSampler.class); >- >- private static final long serialVersionUID = 240L; >- >- public static final String XML_DATA = "HTTPSamper.xml_data"; //$NON-NLS-1$ >- >- public static final String URL_DATA = "SoapSampler.URL_DATA"; //$NON-NLS-1$ >- >- public static final String SOAP_ACTION = "SoapSampler.SOAP_ACTION"; //$NON-NLS-1$ >- >- public static final String SEND_SOAP_ACTION = "SoapSampler.SEND_SOAP_ACTION"; //$NON-NLS-1$ >- >- public static final String XML_DATA_FILE = "SoapSampler.xml_data_file"; //$NON-NLS-1$ >- >- private static final String DOUBLE_QUOTE = "\""; //$NON-NLS-1$ >- >- private static final String SOAPACTION = "SOAPAction"; //$NON-NLS-1$ >- >- private static final String ENCODING = "utf-8"; //$NON-NLS-1$ TODO should this be variable? >- >- private static final String DEFAULT_CONTENT_TYPE = "text/xml"; //$NON-NLS-1$ >- >- public void setXmlData(String data) { >- setProperty(XML_DATA, data); >- } >- >- public String getXmlData() { >- return getPropertyAsString(XML_DATA); >- } >- >- /** >- * it's kinda obvious, but we state it anyways. Set the xml file with a >- * string path. >- * >- * @param filename path to the xml file >- */ >- public void setXmlFile(String filename) { >- setProperty(XML_DATA_FILE, filename); >- } >- >- /** >- * Get the file location of the xml file. >- * >- * @return String file path. >- */ >- public String getXmlFile() { >- return getPropertyAsString(XML_DATA_FILE); >- } >- >- public String getURLData() { >- return getPropertyAsString(URL_DATA); >- } >- >- public void setURLData(String url) { >- setProperty(URL_DATA, url); >- } >- >- public String getSOAPAction() { >- return getPropertyAsString(SOAP_ACTION); >- } >- >- public String getSOAPActionQuoted() { >- String action = getSOAPAction(); >- StringBuilder sb = new StringBuilder(action.length()+2); >- sb.append(DOUBLE_QUOTE); >- sb.append(action); >- sb.append(DOUBLE_QUOTE); >- return sb.toString(); >- } >- >- public void setSOAPAction(String action) { >- setProperty(SOAP_ACTION, action); >- } >- >- public boolean getSendSOAPAction() { >- return getPropertyAsBoolean(SEND_SOAP_ACTION); >- } >- >- public void setSendSOAPAction(boolean action) { >- setProperty(SEND_SOAP_ACTION, String.valueOf(action)); >- } >- >- protected int setPostHeaders(PostMethod post) { >- int length=0;// Take length from file >- if (getHeaderManager() != null) { >- // headerManager was set, so let's set the connection >- // to use it. >- HeaderManager mngr = getHeaderManager(); >- int headerSize = mngr.size(); >- for (int idx = 0; idx < headerSize; idx++) { >- Header hd = mngr.getHeader(idx); >- if (HTTPConstants.HEADER_CONTENT_LENGTH.equalsIgnoreCase(hd.getName())) {// Use this to override file length >- length = Integer.parseInt(hd.getValue()); >- break; >- } >- // All the other headers are set up by HTTPSampler2.setupConnection() >- } >- } else { >- // otherwise we use "text/xml" as the default >- post.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE, DEFAULT_CONTENT_TYPE); //$NON-NLS-1$ >- } >- if (getSendSOAPAction()) { >- post.setRequestHeader(SOAPACTION, getSOAPActionQuoted()); >- } >- return length; >- } >- >- /** >- * Send POST data from <code>Entry</code> to the open connection. >- * >- * @param post POST request to send >- * @param length the length of the content >- */ >- private String sendPostData(PostMethod post, final int length) { >- // Buffer to hold the post body, except file content >- StringBuilder postedBody = new StringBuilder(1000); >- final String xmlFile = getXmlFile(); >- if (xmlFile != null && xmlFile.length() > 0) { >- File xmlFileAsFile = new File(xmlFile); >- if(!(xmlFileAsFile.exists() && xmlFileAsFile.canRead())) { >- throw new IllegalArgumentException(JMeterUtils.getResString("soap_sampler_file_invalid") // $NON-NLS-1$ >- + xmlFileAsFile.getAbsolutePath()); >- } >- // We just add placeholder text for file content >- postedBody.append("Filename: ").append(xmlFile).append("\n"); >- postedBody.append("<actual file content, not shown here>"); >- post.setRequestEntity(new RequestEntity() { >- @Override >- public boolean isRepeatable() { >- return true; >- } >- >- @Override >- public void writeRequest(OutputStream out) throws IOException { >- try (InputStream fileStream = new FileInputStream(xmlFile); >- InputStream in = new BufferedInputStream(fileStream)) { >- IOUtils.copy(in, out); >- out.flush(); >- } >- } >- >- @Override >- public long getContentLength() { >- switch(length){ >- case -1: >- return -1; >- case 0: // No header provided >- return new File(xmlFile).length(); >- default: >- return length; >- } >- } >- >- @Override >- public String getContentType() { >- // TODO do we need to add a charset for the file contents? >- return DEFAULT_CONTENT_TYPE; // $NON-NLS-1$ >- } >- }); >- } else { >- postedBody.append(getXmlData()); >- post.setRequestEntity(new RequestEntity() { >- @Override >- public boolean isRepeatable() { >- return true; >- } >- >- @Override >- public void writeRequest(OutputStream out) throws IOException { >- // charset must agree with content-type below >- IOUtils.write(getXmlData(), out, ENCODING); // $NON-NLS-1$ >- out.flush(); >- } >- >- @Override >- public long getContentLength() { >- try { >- return getXmlData().getBytes(ENCODING).length; // so we don't generate chunked encoding >- } catch (UnsupportedEncodingException e) { >- log.warn(e.getLocalizedMessage()); >- return -1; // will use chunked encoding >- } >- } >- >- @Override >- public String getContentType() { >- return DEFAULT_CONTENT_TYPE+"; charset="+ENCODING; // $NON-NLS-1$ >- } >- }); >- } >- return postedBody.toString(); >- } >- >- @Override >- protected HTTPSampleResult sample(URL url, String method, boolean areFollowingRedirect, int frameDepth) { >- >- String urlStr = url.toString(); >- >- log.debug("Start : sample " + urlStr); >- >- PostMethod httpMethod; >- httpMethod = new PostMethod(urlStr); >- >- HTTPSampleResult res = new HTTPSampleResult(); >- >- res.setSampleLabel(urlStr); // May be replaced later >- res.setHTTPMethod(HTTPConstants.POST); >- res.setURL(url); >- res.sampleStart(); // Count the retries as well in the time >- HttpClient client = null; >- InputStream instream = null; >- try { >- int content_len = setPostHeaders(httpMethod); >- client = setupConnection(url, httpMethod, res); >- setSavedClient(client); >- >- res.setQueryString(sendPostData(httpMethod,content_len)); >- int statusCode = client.executeMethod(httpMethod); >- // Some headers are set by executeMethod() >- res.setRequestHeaders(getConnectionHeaders(httpMethod)); >- >- // Request sent. Now get the response: >- instream = httpMethod.getResponseBodyAsStream(); >- >- if (instream != null) {// will be null for HEAD >- >- org.apache.commons.httpclient.Header responseHeader = httpMethod.getResponseHeader(HTTPConstants.HEADER_CONTENT_ENCODING); >- if (responseHeader != null && HTTPConstants.ENCODING_GZIP.equals(responseHeader.getValue())) { >- instream = new GZIPInputStream(instream); >- } >- >- //int contentLength = httpMethod.getResponseContentLength();Not visible ... >- //TODO size ouststream according to actual content length >- ByteArrayOutputStream outstream = new ByteArrayOutputStream(4 * 1024); >- //contentLength > 0 ? contentLength : DEFAULT_INITIAL_BUFFER_SIZE); >- byte[] buffer = new byte[4096]; >- int len; >- boolean first = true;// first response >- while ((len = instream.read(buffer)) > 0) { >- if (first) { // save the latency >- res.latencyEnd(); >- first = false; >- } >- outstream.write(buffer, 0, len); >- } >- >- res.setResponseData(outstream.toByteArray()); >- outstream.close(); >- >- } >- >- res.sampleEnd(); >- // Done with the sampling proper. >- >- // Now collect the results into the HTTPSampleResult: >- >- res.setSampleLabel(httpMethod.getURI().toString()); >- // Pick up Actual path (after redirects) >- >- res.setResponseCode(Integer.toString(statusCode)); >- res.setSuccessful(isSuccessCode(statusCode)); >- >- res.setResponseMessage(httpMethod.getStatusText()); >- >- // Set up the defaults (may be overridden below) >- res.setDataEncoding(ENCODING); >- res.setContentType(DEFAULT_CONTENT_TYPE); >- String ct = null; >- org.apache.commons.httpclient.Header h >- = httpMethod.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE); >- if (h != null)// Can be missing, e.g. on redirect >- { >- ct = h.getValue(); >- res.setContentType(ct);// e.g. text/html; charset=ISO-8859-1 >- res.setEncodingAndType(ct); >- } >- >- res.setResponseHeaders(getResponseHeaders(httpMethod)); >- if (res.isRedirect()) { >- res.setRedirectLocation(httpMethod.getResponseHeader(HTTPConstants.HEADER_LOCATION).getValue()); >- } >- >- // If we redirected automatically, the URL may have changed >- if (getAutoRedirects()) { >- res.setURL(new URL(httpMethod.getURI().toString())); >- } >- >- // Store any cookies received in the cookie manager: >- saveConnectionCookies(httpMethod, res.getURL(), getCookieManager()); >- >- // Save cache information >- final CacheManager cacheManager = getCacheManager(); >- if (cacheManager != null){ >- cacheManager.saveDetails(httpMethod, res); >- } >- >- // Follow redirects and download page resources if appropriate: >- res = resultProcessing(areFollowingRedirect, frameDepth, res); >- >- log.debug("End : sample"); >- httpMethod.releaseConnection(); >- return res; >- } catch (IllegalArgumentException | IOException e)// e.g. some kinds of invalid URL >- { >- res.sampleEnd(); >- errorResult(e, res); >- return res; >- } finally { >- JOrphanUtils.closeQuietly(instream); >- setSavedClient(null); >- httpMethod.releaseConnection(); >- } >- } >- >- @Override >- public URL getUrl() throws MalformedURLException { >- return new URL(getURLData()); >- } >-} >Index: src/protocol/http/org/apache/jmeter/protocol/http/util/LoopbackHttpClientSocketFactory.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/util/LoopbackHttpClientSocketFactory.java (revision 1781762) >+++ src/protocol/http/org/apache/jmeter/protocol/http/util/LoopbackHttpClientSocketFactory.java (nonexistent) >@@ -1,97 +0,0 @@ >-/* >- * 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. >- * >- */ >- >-package org.apache.jmeter.protocol.http.util; >- >-import java.io.IOException; >-import java.net.InetAddress; >-import java.net.Socket; >-import java.net.URL; >-import java.net.URLConnection; >-import java.net.URLStreamHandler; >-import java.net.URLStreamHandlerFactory; >-import java.net.UnknownHostException; >- >-import org.apache.commons.httpclient.ConnectTimeoutException; >-import org.apache.commons.httpclient.params.HttpConnectionParams; >-import org.apache.commons.httpclient.protocol.Protocol; >-import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; >- >-/** >- * Commons HttpClient protocol factory to generate Loopback HTTP sockets >- * @deprecated since 3.0, will be removed in next version >- */ >-@Deprecated >-public class LoopbackHttpClientSocketFactory implements ProtocolSocketFactory { >- >- public LoopbackHttpClientSocketFactory() { >- super(); >- } >- >- @Override >- public Socket createSocket(String host, int port, InetAddress clientHost, >- int clientPort) throws IOException, UnknownHostException { >- return new LoopbackHTTPSocket(host,port,clientHost,clientPort); >- } >- >- @Override >- public Socket createSocket(String host, int port) throws IOException, >- UnknownHostException { >- return new LoopbackHTTPSocket(host,port); >- } >- >- @Override >- public Socket createSocket(String host, int port, InetAddress localAddress, int localPort, >- HttpConnectionParams params) >- throws IOException, UnknownHostException, ConnectTimeoutException { >- int timeout = params.getConnectionTimeout(); >- if (timeout == 0) { >- return new LoopbackHTTPSocket(host,port,localAddress,localPort); >- } else { >- return new LoopbackHTTPSocket(host,port,localAddress,localPort, timeout); >- } >- } >- >- /** >- * Convenience method to set up the necessary HttpClient protocol and URL handler. >- * >- * Only works for HttpClient, because it's not possible (or at least very difficult) >- * to provide a different socket factory for the HttpURLConnection class. >- */ >- public static void setup(){ >- final String LOOPBACK = "loopback"; // $NON-NLS-1$ >- >- // This ensures tha HttpClient knows about the protocol >- Protocol.registerProtocol(LOOPBACK, new Protocol(LOOPBACK,new LoopbackHttpClientSocketFactory(),1)); >- >- // Now allow the URL handling to work. >- URLStreamHandlerFactory ushf = protocol -> { >- if (protocol.equalsIgnoreCase(LOOPBACK)){ >- return new URLStreamHandler(){ >- @Override >- protected URLConnection openConnection(URL u) throws IOException { >- return null;// not needed for HttpClient >- } >- }; >- } >- return null; >- }; >- >- java.net.URL.setURLStreamHandlerFactory(ushf); >- } >-} >Index: src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHttpClientSocketFactory.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHttpClientSocketFactory.java (revision 1781762) >+++ src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHttpClientSocketFactory.java (nonexistent) >@@ -1,72 +0,0 @@ >-/* >- * 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. >- * >- */ >- >-package org.apache.jmeter.protocol.http.util; >- >-import java.io.IOException; >-import java.net.InetAddress; >-import java.net.Socket; >-import java.net.UnknownHostException; >- >-import org.apache.commons.httpclient.ConnectTimeoutException; >-import org.apache.commons.httpclient.params.HttpConnectionParams; >-import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; >-import org.apache.jmeter.util.SlowSocket; >- >-/** >- * Commons HttpClient protocol factory to generate "slow" sockets for emulating dial-up modems >- * @deprecated since 3.0, will be removed in next version >- */ >-@Deprecated >-public class SlowHttpClientSocketFactory implements ProtocolSocketFactory { >- >- private final int CPS; // Characters per second to emulate >- >- /** >- * >- * @param cps - characters per second >- */ >- public SlowHttpClientSocketFactory(final int cps) { >- super(); >- CPS = cps; >- } >- >- @Override >- public Socket createSocket(String host, int port, InetAddress clientHost, >- int clientPort) throws IOException, UnknownHostException { >- return new SlowSocket(CPS,host,port,clientHost,clientPort); >- } >- >- @Override >- public Socket createSocket(String host, int port) throws IOException, >- UnknownHostException { >- return new SlowSocket(CPS,host,port); >- } >- >- @Override >- public Socket createSocket(String host, int port, InetAddress localAddress, int localPort, >- HttpConnectionParams params) >- throws IOException, UnknownHostException, ConnectTimeoutException { >- int timeout = params.getConnectionTimeout(); >- if (timeout == 0) { >- return new SlowSocket(CPS,host,port,localAddress,localPort); >- } else { >- return new SlowSocket(CPS,host,port,localAddress,localPort, timeout); >- } >- } >-} >Index: test/src/org/apache/jmeter/protocol/http/control/TestCacheManagerHttpMethod.java >=================================================================== >--- test/src/org/apache/jmeter/protocol/http/control/TestCacheManagerHttpMethod.java (revision 1782633) >+++ test/src/org/apache/jmeter/protocol/http/control/TestCacheManagerHttpMethod.java (nonexistent) >@@ -1,68 +0,0 @@ >-/* >- * 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. >- * >- */ >- >-package org.apache.jmeter.protocol.http.control; >- >-import org.apache.commons.httpclient.Header; >-import org.apache.jmeter.protocol.http.sampler.HTTPSampleResult; >-import org.apache.jmeter.protocol.http.util.HTTPConstants; >- >-import static org.junit.Assert.assertEquals; >- >-public class TestCacheManagerHttpMethod extends TestCacheManagerUrlConnectionBase { >- >- @Override >- protected void setExpires(String expires) { >- ((HttpMethodStub) httpMethod).expires = expires; >- } >- >- @Override >- protected void setCacheControl(String cacheControl) { >- ((HttpMethodStub) httpMethod).cacheControl = cacheControl; >- } >- >- @Override >- protected void setLastModified(String lastModified) { >- ((HttpMethodStub) httpMethod).lastModifiedHeader = >- new org.apache.commons.httpclient.Header(HTTPConstants.LAST_MODIFIED, >- lastModified); >- } >- >- @Override >- protected void cacheResult(HTTPSampleResult result) throws Exception { >- this.cacheManager.saveDetails(this.httpMethod, result); >- } >- >- @Override >- protected void addRequestHeader(String requestHeader, String value) { >- this.httpMethod.addRequestHeader(new Header(requestHeader, value, false)); >- } >- >- @Override >- protected void setRequestHeaders() { >- this.cacheManager.setHeaders(this.url, this.httpMethod); >- } >- >- @Override >- protected void checkRequestHeader(String requestHeader, String expectedValue) { >- org.apache.commons.httpclient.Header header = this.httpMethod.getRequestHeader(requestHeader); >- assertEquals("Wrong name in header for " + requestHeader, requestHeader, header.getName()); >- assertEquals("Wrong value for header " + header, expectedValue, header.getValue()); >- } >- >-} >Index: test/src/org/apache/jmeter/protocol/http/control/TestCacheManagerUrlConnection.java >=================================================================== >--- test/src/org/apache/jmeter/protocol/http/control/TestCacheManagerUrlConnection.java (revision 1782633) >+++ test/src/org/apache/jmeter/protocol/http/control/TestCacheManagerUrlConnection.java (working copy) >@@ -18,14 +18,15 @@ > > package org.apache.jmeter.protocol.http.control; > >+import static org.junit.Assert.assertEquals; >+import static org.junit.Assert.assertNotNull; >+ >+import java.net.HttpURLConnection; > import java.util.List; > import java.util.Map; > > import org.apache.jmeter.protocol.http.sampler.HTTPSampleResult; > >-import static org.junit.Assert.assertEquals; >-import static org.junit.Assert.assertNotNull; >- > public class TestCacheManagerUrlConnection extends TestCacheManagerUrlConnectionBase { > > @Override >@@ -50,7 +51,7 @@ > > @Override > protected void checkRequestHeader(String requestHeader, String expectedValue) { >- Map<String, List<String>> properties = this.httpUrlConnection.getRequestProperties(); >+ Map<String, List<String>> properties = ((HttpURLConnection)this.urlConnection).getRequestProperties(); > checkProperty(properties, requestHeader, expectedValue); > } > >@@ -61,7 +62,7 @@ > > @Override > protected void setRequestHeaders() { >- this.cacheManager.setHeaders(this.httpUrlConnection, this.url); >+ this.cacheManager.setHeaders((HttpURLConnection)this.urlConnection, this.url); > } > > private static void checkProperty(Map<String, List<String>> properties, String property, String expectedPropertyValue) { >Index: test/src/org/apache/jmeter/protocol/http/control/TestCacheManagerUrlConnectionBase.java >=================================================================== >--- test/src/org/apache/jmeter/protocol/http/control/TestCacheManagerUrlConnectionBase.java (revision 1782730) >+++ test/src/org/apache/jmeter/protocol/http/control/TestCacheManagerUrlConnectionBase.java (working copy) >@@ -19,22 +19,14 @@ > package org.apache.jmeter.protocol.http.control; > > import java.io.IOException; >+import java.net.HttpURLConnection; > import java.net.URL; > import java.net.URLConnection; >-import java.util.ArrayList; >-import java.util.HashMap; >-import java.util.List; >-import java.util.Map; > >-import org.apache.commons.httpclient.HttpMethod; >-import org.apache.commons.httpclient.URI; >-import org.apache.commons.httpclient.URIException; >-import org.apache.commons.httpclient.methods.PostMethod; >-import org.apache.commons.httpclient.util.HttpURLConnection; > import org.apache.jmeter.protocol.http.util.HTTPConstants; > > public abstract class TestCacheManagerUrlConnectionBase extends TestCacheManagerBase { >- protected class URLConnectionStub extends URLConnection { >+ protected class URLConnectionStub extends HttpURLConnection { > > protected URLConnectionStub(URL url) { > super(url); >@@ -74,88 +66,27 @@ > public URL getURL() { > return url; > } >- } >- >- protected class HttpMethodStub extends PostMethod { >- protected org.apache.commons.httpclient.Header lastModifiedHeader; >- protected org.apache.commons.httpclient.Header etagHeader; >- protected String expires; >- protected String cacheControl; >- protected org.apache.commons.httpclient.Header dateHeader; >- >- HttpMethodStub() { >- this.lastModifiedHeader = new org.apache.commons.httpclient.Header(HTTPConstants.LAST_MODIFIED, currentTimeInGMT); >- this.dateHeader = new org.apache.commons.httpclient.Header(HTTPConstants.DATE, currentTimeInGMT); >- this.etagHeader = new org.apache.commons.httpclient.Header(HTTPConstants.ETAG, EXPECTED_ETAG); >- } > > @Override >- public org.apache.commons.httpclient.Header getResponseHeader(String headerName) { >- if (HTTPConstants.LAST_MODIFIED.equals(headerName)) { >- return this.lastModifiedHeader; >- } else if (HTTPConstants.ETAG.equals(headerName)) { >- return this.etagHeader; >- } else if (HTTPConstants.EXPIRES.equals(headerName)) { >- return expires == null ? null : new org.apache.commons.httpclient.Header(HTTPConstants.EXPIRES, expires); >- } else if (HTTPConstants.CACHE_CONTROL.equals(headerName)) { >- return cacheControl == null ? null : new org.apache.commons.httpclient.Header(HTTPConstants.CACHE_CONTROL, cacheControl); >- } else if (HTTPConstants.DATE.equals(headerName)) { >- return this.dateHeader; >- } else if (HTTPConstants.VARY.equals(headerName)) { >- return vary == null ? null : new org.apache.commons.httpclient.Header(HTTPConstants.VARY, vary); >- } >- return null; >+ public void disconnect() { > } > > @Override >- public URI getURI() throws URIException { >- return uri; >+ public boolean usingProxy() { >+ return false; > } > } >- >- private static class HttpURLConnectionStub extends HttpURLConnection { >- private Map<String, List<String>> properties; >- >- public HttpURLConnectionStub(HttpMethod method, URL url) { >- super(method, url); >- this.properties = new HashMap<>(); >- } >- >- @Override >- public void addRequestProperty(String key, String value) { >- List<String> list = new ArrayList<>(); >- list.add(value); >- this.properties.put(key, list); >- } >- >- @Override >- public Map<String, List<String>> getRequestProperties() { >- return this.properties; >- } >- >- } >- >- private URI uri; > protected URLConnection urlConnection; >- protected HttpMethod httpMethod; >- protected HttpURLConnection httpUrlConnection; > > @Override > public void setUp() throws Exception { > super.setUp(); >- this.uri = new URI(LOCAL_HOST, false); > this.urlConnection = new URLConnectionStub(this.url.openConnection()); >- this.httpMethod = new HttpMethodStub(); >- this.httpUrlConnection = new HttpURLConnectionStub(this.httpMethod, this.url); >- this.httpMethod.setURI(this.uri); > } > > @Override > public void tearDown() throws Exception { >- this.httpUrlConnection = null; >- this.httpMethod = null; > this.urlConnection = null; >- this.uri = null; > super.tearDown(); > } > } >Index: test/src/org/apache/jmeter/protocol/http/control/TestDNSCacheManager.java >=================================================================== >--- test/src/org/apache/jmeter/protocol/http/control/TestDNSCacheManager.java (revision 1782633) >+++ test/src/org/apache/jmeter/protocol/http/control/TestDNSCacheManager.java (working copy) >@@ -105,7 +105,7 @@ > Assert.assertTrue(original.cache.size()==1); > // OK > } catch (UnknownHostException e) { >- fail("System DNS server should have been used"); >+ fail("Should have succeeded resolving jmeter.apache.org, error:"+e.getMessage()); > } > } > >Index: test/src/org/apache/jmeter/protocol/http/control/TestHC3CookieManager.java >=================================================================== >--- test/src/org/apache/jmeter/protocol/http/control/TestHC3CookieManager.java (revision 1782633) >+++ test/src/org/apache/jmeter/protocol/http/control/TestHC3CookieManager.java (nonexistent) >@@ -1,459 +0,0 @@ >-/* >- * 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. >- * >- */ >- >-package org.apache.jmeter.protocol.http.control; >- >-import static org.junit.Assert.assertEquals; >-import static org.junit.Assert.assertFalse; >-import static org.junit.Assert.assertNotNull; >-import static org.junit.Assert.assertNull; >-import static org.junit.Assert.assertTrue; >- >-import java.net.URL; >- >-import org.apache.commons.httpclient.cookie.CookiePolicy; >-import org.apache.jmeter.junit.JMeterTestCase; >-import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler; >-import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; >-import org.apache.jmeter.protocol.http.util.HTTPConstants; >-import org.apache.jmeter.threads.JMeterContext; >-import org.apache.jmeter.threads.JMeterContextService; >-import org.junit.Before; >-import org.junit.Test; >- >-/** >- * HC3CookieHandler tests >- */ >-@SuppressWarnings("deprecation") // unit test of deprecated class >-public class TestHC3CookieManager extends JMeterTestCase { >- private CookieManager man = null; >- >- private JMeterContext jmctx = null; >- >- @Before >- public void setUp() throws Exception { >- jmctx = JMeterContextService.getContext(); >- man = new CookieManager(); // defaults to HC3/compatibility >- // but make double-sure that this is the case >- man.setImplementation(HC3CookieHandler.class.getName()); >- man.setCookiePolicy(HC3CookieHandler.DEFAULT_POLICY_NAME); >- man.setThreadContext(jmctx); >- man.testStarted();// This is needed in order to set up the cookie policy >- } >- >- @Test >- public void testRemoveCookie() throws Exception { >- man.setThreadContext(jmctx); >- Cookie c = new Cookie("id", "me", "127.0.0.1", "/", false, 0); >- man.add(c); >- assertEquals(1, man.getCookieCount()); >- // This should be ignored, as there is no value >- Cookie d = new Cookie("id", "", "127.0.0.1", "/", false, 0); >- man.add(d); >- assertEquals(0, man.getCookieCount()); >- man.add(c); >- man.add(c); >- assertEquals(1, man.getCookieCount()); >- Cookie e = new Cookie("id", "me2", "127.0.0.1", "/", false, 0); >- man.add(e); >- assertEquals(1, man.getCookieCount()); >- } >- >- @Test >- public void testSendCookie() throws Exception { >- man.add(new Cookie("id", "value", "jakarta.apache.org", "/", false, 9999999999L)); >- HTTPSamplerBase sampler = new HTTPNullSampler(); >- sampler.setDomain("jakarta.apache.org"); >- sampler.setPath("/index.html"); >- sampler.setMethod(HTTPConstants.GET); >- assertNotNull(man.getCookieHeaderForURL(sampler.getUrl())); >- } >- >- @Test >- public void testSendCookie2() throws Exception { >- man.add(new Cookie("id", "value", ".apache.org", "/", false, 9999999999L)); >- HTTPSamplerBase sampler = new HTTPNullSampler(); >- sampler.setDomain("jakarta.apache.org"); >- sampler.setPath("/index.html"); >- sampler.setMethod(HTTPConstants.GET); >- assertNotNull(man.getCookieHeaderForURL(sampler.getUrl())); >- } >- >- /** >- * Test that the cookie domain field is actually handled as browsers do >- * (i.e.: host X matches domain .X): >- * >- * @throws Exception if something fails >- */ >- @Test >- public void testDomainHandling() throws Exception { >- URL url = new URL("http://jakarta.apache.org/"); >- man.addCookieFromHeader("test=1;domain=.jakarta.apache.org", url); >- assertNotNull(man.getCookieHeaderForURL(url)); >- } >- >- @Test >- public void testCrossDomainHandling() throws Exception { >- URL url = new URL("http://jakarta.apache.org/"); >- assertEquals(0,man.getCookieCount()); // starts empty >- man.addCookieFromHeader("test=2;domain=.hc.apache.org", url); >- assertEquals(0,man.getCookieCount()); // should not be stored >- man.addCookieFromHeader("test=1;domain=.jakarta.apache.org", url); >- assertEquals(1,man.getCookieCount()); // OK >- } >- >- /** >- * Test that we won't be tricked by similar host names (this was a past >- * bug, although it never got reported in the bug database): >- * >- * @throws Exception if something fails >- */ >- @Test >- public void testSimilarHostNames() throws Exception { >- URL url = new URL("http://ache.org/"); >- man.addCookieFromHeader("test=1", url); >- url = new URL("http://jakarta.apache.org/"); >- assertNull(man.getCookieHeaderForURL(url)); >- } >- >- // Test session cookie is returned >- @Test >- public void testSessionCookie() throws Exception { >- URL url = new URL("http://a.b.c/"); >- man.addCookieFromHeader("test=1", url); >- String s = man.getCookieHeaderForURL(url); >- assertNotNull(s); >- assertEquals("test=1", s); >- } >- >- // Bug 2063 >- @Test >- public void testCookieWithEquals() throws Exception { >- URL url = new URL("http://a.b.c/"); >- man.addCookieFromHeader("NSCP_USER_LOGIN1_NEW=SHA=xxxxx", url); >- String s = man.getCookieHeaderForURL(url); >- assertNotNull(s); >- assertEquals("NSCP_USER_LOGIN1_NEW=SHA=xxxxx", s); >- Cookie c=man.get(0); >- assertEquals("NSCP_USER_LOGIN1_NEW",c.getName()); >- assertEquals("SHA=xxxxx",c.getValue()); >- } >- >- // Test Old cookie is not returned >- @Test >- public void testOldCookie() throws Exception { >- URL url = new URL("http://a.b.c/"); >- man.addCookieFromHeader("test=1; expires=Mon, 01-Jan-1990 00:00:00 GMT", url); >- String s = man.getCookieHeaderForURL(url); >- assertNull(s); >- } >- >- // Test New cookie is returned >- @Test >- public void testNewCookie() throws Exception { >- URL url = new URL("http://a.b.c/"); >- man.addCookieFromHeader("test=1; expires=Mon, 01-Jan-2990 00:00:00 GMT", url); >- assertEquals(1,man.getCookieCount()); >- String s = man.getCookieHeaderForURL(url); >- assertNotNull(s); >- assertEquals("test=1", s); >- } >- >- // Test multi-cookie header handling >- @Test >- public void testCookies1() throws Exception { >- URL url = new URL("http://a.b.c.d/testCookies1"); >- man.addCookieFromHeader("test1=1; comment=\"how,now\", test2=2; version=1", url); >- assertEquals(2,man.getCookieCount()); >- String s = man.getCookieHeaderForURL(url); >- assertNotNull(s); >- assertEquals("test1=1; test2=2", s); >- } >- >- @Test >- public void testCookies2() throws Exception { >- URL url = new URL("https://a.b.c.d/testCookies2"); >- man.addCookieFromHeader("test1=1;secure, test2=2;secure", url); >- assertEquals(2,man.getCookieCount()); >- String s = man.getCookieHeaderForURL(url); >- assertNotNull(s); >- assertEquals("test1=1; test2=2", s); >- } >- >- // Test duplicate cookie handling >- @Test >- public void testDuplicateCookie() throws Exception { >- URL url = new URL("http://a.b.c/"); >- man.addCookieFromHeader("test=1", url); >- String s = man.getCookieHeaderForURL(url); >- assertNotNull(s); >- assertEquals("test=1", s); >- man.addCookieFromHeader("test=2", url); >- s = man.getCookieHeaderForURL(url); >- assertNotNull(s); >- assertEquals("test=2", s); >- } >- >- @Test >- public void testDuplicateCookie2() throws Exception { >- URL url = new URL("http://a.b.c/"); >- man.addCookieFromHeader("test=1", url); >- man.addCookieFromHeader("test2=a", url); >- String s = man.getCookieHeaderForURL(url); >- assertNotNull(s); >- assertEquals("test=1; test2=a", s); // Assumes some kind of list is used >- man.addCookieFromHeader("test=2", url); >- man.addCookieFromHeader("test3=b", url); >- s = man.getCookieHeaderForURL(url); >- assertNotNull(s); >- assertEquals("test2=a; test=2; test3=b", s);// Assumes some kind of list is use >- // If not using a list that retains the order, then the asserts would need to change >- } >- >- >- /** Tests missing cookie path for a trivial URL fetch from the domain >- * Note that this fails prior to a fix for BUG 38256 >- * >- * @throws Exception if something fails >- */ >- @Test >- public void testMissingPath0() throws Exception { >- URL url = new URL("http://d.e.f/goo.html"); >- man.addCookieFromHeader("test=moo", url); >- String s = man.getCookieHeaderForURL(new URL("http://d.e.f/")); >- assertNotNull(s); >- assertEquals("test=moo", s); >- } >- >- /** Tests missing cookie path for a non-trivial URL fetch from the >- * domain. Note that this fails prior to a fix for BUG 38256 >- * >- * @throws Exception if something fails >- */ >- @Test >- public void testMissingPath1() throws Exception { >- URL url = new URL("http://d.e.f/moo.html"); >- man.addCookieFromHeader("test=moo", url); >- String s = man.getCookieHeaderForURL(new URL("http://d.e.f/goo.html")); >- assertNotNull(s); >- assertEquals("test=moo", s); >- } >- >- /** Tests explicit root path with a trivial URL fetch from the domain >- * >- * @throws Exception if something fails >- */ >- @Test >- public void testRootPath0() throws Exception { >- URL url = new URL("http://d.e.f/goo.html"); >- man.addCookieFromHeader("test=moo;path=/", url); >- String s = man.getCookieHeaderForURL(new URL("http://d.e.f/")); >- assertNotNull(s); >- assertEquals("test=moo", s); >- } >- >- /** Tests explicit root path with a non-trivial URL fetch from the domain >- * >- * @throws Exception if something fails >- */ >- @Test >- public void testRootPath1() throws Exception { >- URL url = new URL("http://d.e.f/moo.html"); >- man.addCookieFromHeader("test=moo;path=/", url); >- String s = man.getCookieHeaderForURL(new URL("http://d.e.f/goo.html")); >- assertNotNull(s); >- assertEquals("test=moo", s); >- } >- >- // Test cookie matching >- @Test >- public void testCookieMatching() throws Exception { >- URL url = new URL("http://a.b.c:8080/TopDir/fred.jsp"); >- man.addCookieFromHeader("ID=abcd; Path=/TopDir", url); >- String s = man.getCookieHeaderForURL(url); >- assertNotNull(s); >- assertEquals("ID=abcd", s); >- >- url = new URL("http://a.b.c:8080/other.jsp"); >- s=man.getCookieHeaderForURL(url); >- assertNull(s); >- >- url = new URL("http://a.b.c:8080/TopDir/suub/another.jsp"); >- s=man.getCookieHeaderForURL(url); >- assertNotNull(s); >- >- url = new URL("http://a.b.c:8080/TopDir"); >- s=man.getCookieHeaderForURL(url); >- assertNotNull(s); >- >- url = new URL("http://a.b.d/"); >- s=man.getCookieHeaderForURL(url); >- assertNull(s); >- } >- >- @Test >- public void testCookieOrdering1() throws Exception { >- URL url = new URL("http://order.now/sub1/moo.html"); >- man.addCookieFromHeader("test1=moo1;path=/", url); >- man.addCookieFromHeader("test2=moo2;path=/sub1", url); >- man.addCookieFromHeader("test2=moo3;path=/", url); >- assertEquals(3,man.getCookieCount()); >- String s = man.getCookieHeaderForURL(url); >- assertNotNull(s); >- assertEquals("test2=moo2; test1=moo1; test2=moo3", s); >- } >- >- @Test >- public void testCookieOrdering2() throws Exception { >- URL url = new URL("http://order.now/sub1/moo.html"); >- man.addCookieFromHeader("test1=moo1;", url); >- man.addCookieFromHeader("test2=moo2;path=/sub1", url); >- man.addCookieFromHeader("test2=moo3;path=/", url); >- assertEquals(3,man.getCookieCount()); >- assertEquals("/sub1",man.get(0).getPath()); // Defaults to caller URL >- assertEquals("/sub1",man.get(1).getPath()); >- assertEquals("/",man.get(2).getPath()); >- String s = man.getCookieHeaderForURL(url); >- assertNotNull(s); >- HC3CookieHandler hc3CookieHandler = (HC3CookieHandler) man.getCookieHandler(); >- org.apache.commons.httpclient.Cookie[] c = >- hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, >- CookieManager.ALLOW_VARIABLE_COOKIES); >- assertEquals("/sub1",c[0].getPath()); >- assertFalse(c[0].isPathAttributeSpecified()); >- assertEquals("/sub1",c[1].getPath()); >- assertTrue(c[1].isPathAttributeSpecified()); >- assertEquals("/",c[2].getPath()); >- assertEquals("test1=moo1; test2=moo2; test2=moo3", s); >- } >- >- @Test >- public void testCookiePolicy2109() throws Exception { >- man.setCookiePolicy(CookiePolicy.RFC_2109); >- man.testStarted(); // ensure policy is picked up >- URL url = new URL("http://order.now/sub1/moo.html"); >- man.addCookieFromHeader("test1=moo1;", url); >- man.addCookieFromHeader("test2=moo2;path=/sub1", url); >- man.addCookieFromHeader("test2=moo3;path=/", url); >- assertEquals(3,man.getCookieCount()); >- //assertEquals("/",man.get(0).getPath()); >- assertEquals("/sub1",man.get(1).getPath()); >- assertEquals("/",man.get(2).getPath()); >- String s = man.getCookieHeaderForURL(url); >- assertNotNull(s); >- HC3CookieHandler hc3CookieHandler = (HC3CookieHandler) man.getCookieHandler(); >- org.apache.commons.httpclient.Cookie[] c = >- hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, >- CookieManager.ALLOW_VARIABLE_COOKIES); >- assertEquals("/sub1",c[0].getPath()); >- assertFalse(c[0].isPathAttributeSpecified()); >- assertEquals("/sub1",c[1].getPath()); >- assertTrue(c[1].isPathAttributeSpecified()); >- assertEquals("/",c[2].getPath()); >- assertTrue(c[2].isPathAttributeSpecified()); >- assertEquals("$Version=0; test1=moo1; test2=moo2; $Path=/sub1; test2=moo3; $Path=/", s); >- } >- >- @Test >- public void testCookiePolicyNetscape() throws Exception { >- man.setCookiePolicy(CookiePolicy.NETSCAPE); >- man.testStarted(); // ensure policy is picked up >- URL url = new URL("http://www.order.now/sub1/moo.html"); >- man.addCookieFromHeader("test1=moo1;", url); >- man.addCookieFromHeader("test2=moo2;path=/sub1", url); >- man.addCookieFromHeader("test2=moo3;path=/", url); >- assertEquals(3,man.getCookieCount()); >- assertEquals("/sub1",man.get(0).getPath()); >- assertEquals("/sub1",man.get(1).getPath()); >- assertEquals("/",man.get(2).getPath()); >- String s = man.getCookieHeaderForURL(url); >- assertNotNull(s); >- HC3CookieHandler hc3CookieHandler = (HC3CookieHandler) man.getCookieHandler(); >- >- org.apache.commons.httpclient.Cookie[] c = >- hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, >- CookieManager.ALLOW_VARIABLE_COOKIES); >- assertEquals("/sub1",c[0].getPath()); >- assertFalse(c[0].isPathAttributeSpecified()); >- assertEquals("/sub1",c[1].getPath()); >- assertTrue(c[1].isPathAttributeSpecified()); >- assertEquals("/",c[2].getPath()); >- assertTrue(c[2].isPathAttributeSpecified()); >- assertEquals("test1=moo1; test2=moo2; test2=moo3", s); >- } >- >- @Test >- public void testCookiePolicyIgnore() throws Exception { >- man.setCookiePolicy(CookiePolicy.IGNORE_COOKIES); >- man.testStarted(); // ensure policy is picked up >- URL url = new URL("http://order.now/sub1/moo.html"); >- man.addCookieFromHeader("test1=moo1;", url); >- man.addCookieFromHeader("test2=moo2;path=/sub1", url); >- man.addCookieFromHeader("test2=moo3;path=/", url); >- assertEquals(0,man.getCookieCount());// Cookies are ignored >- Cookie cc; >- cc=new Cookie("test1","moo1",null,"/sub1",false,0,false,false); >- man.add(cc); >- cc=new Cookie("test2","moo2",null,"/sub1",false,0,true,false); >- man.add(cc); >- cc=new Cookie("test3","moo3",null,"/",false,0,false,false); >- man.add(cc); >- assertEquals(3,man.getCookieCount()); >- assertEquals("/sub1",man.get(0).getPath()); >- assertEquals("/sub1",man.get(1).getPath()); >- assertEquals("/",man.get(2).getPath()); >- String s = man.getCookieHeaderForURL(url); >- assertNull(s); >- HC3CookieHandler hc3CookieHandler = (HC3CookieHandler) man.getCookieHandler(); >- org.apache.commons.httpclient.Cookie[] c = >- hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, >- CookieManager.ALLOW_VARIABLE_COOKIES); >- assertEquals(0,c.length); // Cookies again ignored >- } >- >- @Test >- public void testLoad() throws Exception{ >- assertEquals(0,man.getCookieCount()); >- man.addFile(findTestPath("testfiles/cookies.txt")); >- assertEquals(3,man.getCookieCount()); >- >- int num = 0; >- assertEquals("name",man.get(num).getName()); >- assertEquals("value",man.get(num).getValue()); >- assertEquals("path",man.get(num).getPath()); >- assertEquals("domain",man.get(num).getDomain()); >- assertTrue(man.get(num).getSecure()); >- assertEquals(num,man.get(num).getExpires()); >- >- num++; >- assertEquals("name2",man.get(num).getName()); >- assertEquals("value2",man.get(num).getValue()); >- assertEquals("/",man.get(num).getPath()); >- assertEquals("",man.get(num).getDomain()); >- assertFalse(man.get(num).getSecure()); >- assertEquals(0,man.get(num).getExpires()); >- >- num++; >- assertEquals("a",man.get(num).getName()); >- assertEquals("b",man.get(num).getValue()); >- assertEquals("d",man.get(num).getPath()); >- assertEquals("c",man.get(num).getDomain()); >- assertTrue(man.get(num).getSecure()); >- assertEquals(0,man.get(num).getExpires()); // Show that maxlong now saved as 0 >- } >-} >Index: test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java >=================================================================== >--- test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java (revision 1781762) >+++ test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java (working copy) >@@ -58,7 +58,6 @@ > */ > public class TestHTTPSamplersAgainstHttpMirrorServer extends JMeterTestCaseJUnit3 { > private static final int HTTP_SAMPLER = 0; >- private static final int HTTP_SAMPLER2 = 1; > private static final int HTTP_SAMPLER3 = 2; > > /** The encodings used for http headers and control information */ >@@ -90,11 +89,9 @@ > // Add parameterised tests. For simplicity we assune each has cases 0-10 > for(int i=0; i<11; i++) { > testSuite.addTest(new TestHTTPSamplersAgainstHttpMirrorServer("itemised_testGetRequest_Parameters", i)); >- testSuite.addTest(new TestHTTPSamplersAgainstHttpMirrorServer("itemised_testGetRequest_Parameters2", i)); > testSuite.addTest(new TestHTTPSamplersAgainstHttpMirrorServer("itemised_testGetRequest_Parameters3", i)); > > testSuite.addTest(new TestHTTPSamplersAgainstHttpMirrorServer("itemised_testPostRequest_UrlEncoded", i)); >- testSuite.addTest(new TestHTTPSamplersAgainstHttpMirrorServer("itemised_testPostRequest_UrlEncoded2", i)); > testSuite.addTest(new TestHTTPSamplersAgainstHttpMirrorServer("itemised_testPostRequest_UrlEncoded3", i)); > } > >@@ -133,10 +130,6 @@ > testPostRequest_UrlEncoded(HTTP_SAMPLER, ISO_8859_1, item); > } > >- public void itemised_testPostRequest_UrlEncoded2() throws Exception { >- testPostRequest_UrlEncoded(HTTP_SAMPLER2, US_ASCII, item); >- } >- > public void itemised_testPostRequest_UrlEncoded3() throws Exception { > testPostRequest_UrlEncoded(HTTP_SAMPLER3, US_ASCII, item); > } >@@ -145,10 +138,6 @@ > testPostRequest_FormMultipart(HTTP_SAMPLER, ISO_8859_1); > } > >- public void testPostRequest_FormMultipart2() throws Exception { >- testPostRequest_FormMultipart(HTTP_SAMPLER2, US_ASCII); >- } >- > public void testPostRequest_FormMultipart3() throws Exception { > // see https://issues.apache.org/jira/browse/HTTPCLIENT-1665 > testPostRequest_FormMultipart(HTTP_SAMPLER3, US_ASCII); >@@ -158,10 +147,6 @@ > testPostRequest_FileUpload(HTTP_SAMPLER, ISO_8859_1); > } > >- public void testPostRequest_FileUpload2() throws Exception { >- testPostRequest_FileUpload(HTTP_SAMPLER2, US_ASCII); >- } >- > public void testPostRequest_FileUpload3() throws Exception { > // see https://issues.apache.org/jira/browse/HTTPCLIENT-1665 > testPostRequest_FileUpload(HTTP_SAMPLER3, US_ASCII); >@@ -171,10 +156,6 @@ > testPostRequest_BodyFromParameterValues(HTTP_SAMPLER, ISO_8859_1); > } > >- public void testPostRequest_BodyFromParameterValues2() throws Exception { >- testPostRequest_BodyFromParameterValues(HTTP_SAMPLER2, US_ASCII); >- } >- > public void testPostRequest_BodyFromParameterValues3() throws Exception { > testPostRequest_BodyFromParameterValues(HTTP_SAMPLER3, US_ASCII); > } >@@ -183,21 +164,13 @@ > testGetRequest(HTTP_SAMPLER); > } > >- public void testGetRequest2() throws Exception { >- testGetRequest(HTTP_SAMPLER2); >- } >- > public void testGetRequest3() throws Exception { > testGetRequest(HTTP_SAMPLER3); > } > > public void itemised_testGetRequest_Parameters() throws Exception { > testGetRequest_Parameters(HTTP_SAMPLER, item); >- } >- >- public void itemised_testGetRequest_Parameters2() throws Exception { >- testGetRequest_Parameters(HTTP_SAMPLER2, item); >- } >+ } > > public void itemised_testGetRequest_Parameters3() throws Exception { > testGetRequest_Parameters(HTTP_SAMPLER3, item); >@@ -1439,10 +1412,6 @@ > switch(samplerType) { > case HTTP_SAMPLER: > return new HTTPSampler(); >- case HTTP_SAMPLER2: >- @SuppressWarnings("deprecation") // unit test of deprecated class >- final HTTPSampler2 httpSampler2 = new HTTPSampler2(); >- return httpSampler2; > case HTTP_SAMPLER3: > return new HTTPSampler3(); > default: >Index: xdocs/usermanual/component_reference.xml >=================================================================== >--- xdocs/usermanual/component_reference.xml (revision 1782700) >+++ xdocs/usermanual/component_reference.xml (working copy) >@@ -456,7 +456,6 @@ > </p> > <source> > httpclient4.retrycount=3 >-httpclient3.retrycount=3 > </source> > <p> > <b>Note: Certificates does not conform to algorithm constraints</b><br></br> >@@ -661,42 +660,6 @@ > <property name="ResultData" required="No">If provided, sets the SampleResult ResultData.</property> > </properties> > </component> >- >-<component name="SOAP/XML-RPC Request (DEPRECATED)" index="§-num;.1.5" width="426" height="276" screenshot="soap_sampler.png"> >-<note> >-See <a href="build-ws-test-plan.html">Building a WebService Test Plan</a> for up to date way of test SOAP and REST Webservices >-</note> >-<description><p>This sampler lets you send a SOAP request to a webservice. It can also be >-used to send XML-RPC over HTTP. It creates an HTTP POST request, with the specified XML as the >-POST content. >-To change the "<code>Content-type</code>" from the default of "<code>text/xml</code>", use a <complink name="HTTP Header Manager" />. >-Note that the sampler will use all the headers from the <complink name="HTTP Header Manager"/>. >-If a SOAP action is specified, that will override any <code>SOAPaction</code> in the <complink name="HTTP Header Manager"/>. >-The primary difference between the soap sampler and >-webservice sampler, is the soap sampler uses raw post and does not require conformance to >-SOAP 1.1.</p> >-<note>The sampler no longer uses chunked encoding by default.<br/> >-For screen input, it now always uses the size of the data.<br/> >-File input uses the file length as determined by Java.<br/> >-On some OSes this may not work for all files, in which case add a child <complink name="HTTP Header Manager"/> >-with <code>Content-Length</code> set to the actual length of the file.<br/> >-Or set <code>Content-Length</code> to <code>-1</code> to force chunked encoding. >-</note> >-</description> >- >-<properties> >- <property name="Name" required="No">Descriptive name for this sampler >- that is shown in the tree.</property> >- <property name="URL" required="Yes">The URL to direct the SOAP request to.</property> >- <property name="Send SOAP action" required="No">Send a SOAP action header? (overrides the <complink name="HTTP Header Manager"/>)</property> >- <property name="Use KeepAlive" required="No">If set, sends <code>Connection: keep-alive</code>, else sends <code>Connection: close</code></property> >- <property name="Soap/XML-RPC Data" required="No">The Soap XML message, or XML-RPC instructions. >- Not used if the filename is provided. >- </property> >- <property name="Filename" required="No">If specified, then the contents of the file are sent, and the Data field is ignored</property> >- </properties> >-</component> >- > <component name="LDAP Request" index="§-num;.1.7" width="621" height="462" screenshot="ldap_request.png"> > <description>This Sampler lets you send a different Ldap request(<code>Add</code>, <code>Modify</code>, <code>Delete</code> and <code>Search</code>) to an LDAP server. > <p>If you are going to send multiple requests to the same LDAP server, consider >Index: xdocs/usermanual/properties_reference.xml >=================================================================== >--- xdocs/usermanual/properties_reference.xml (revision 1782695) >+++ xdocs/usermanual/properties_reference.xml (working copy) >@@ -468,19 +468,7 @@ > </property> > </properties> > </section> >-<section name="§-num;.15 Apache HttpComponents Commons HTTPClient configuration (HTTPClient 3.1)" anchor="httpclient31"> >-<properties> >-<property name="httpclient.parameters.file"> >- Define a properties file for overriding Commons HttpClient parameters. >- See <a href="http://hc.apache.org/httpclient-3.x/preference-api.html">this</a>. >- Uncomment this line if you put anything in <code>httpclient.parameters</code> file. >-</property> >-<property name="httpclient3.retrycount"> >- Number of retries to attempt.<br/> >- Defaults to: <code>0</code> >-</property> >-</properties> >-</section> >+ > <section name="§-num;.16 HTTP Cache Manager configuration" anchor="cache_maanger"> > <properties> > <property name="cacheable_methods">
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 60727
:
34751
| 34752