Proxy Server now removes If-Modified-Since headers by default.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/jmeter/trunk@592492 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2007-11-06 17:24:23 +00:00
parent b4d3fcd1df
commit 22d82a4ef2
4 changed files with 38 additions and 3 deletions

View File

@ -340,6 +340,10 @@ upgrade_properties=/bin/upgrade.properties
# Default content-type exclude filter to use
#proxy.content_type_exclude=image/.*|text/css|application/.*
# Default headers to remove from Header Manager elements
# (Cookie and Authorization are always removed)
#proxy.headers.remove=If-Modified-Since
#---------------------------------------------------------------------------
# JMeter Proxy configuration
#---------------------------------------------------------------------------

View File

@ -35,7 +35,9 @@ import org.apache.jmeter.protocol.http.sampler.HTTPSamplerFactory;
import org.apache.jmeter.protocol.http.util.HTTPConstants;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.jorphan.util.JOrphanUtils;
import org.apache.log.Logger;
/**
@ -46,10 +48,25 @@ import org.apache.log.Logger;
*
*/
public class Proxy extends Thread {
private static final Logger log = LoggingManager.getLoggerForClass();
private static final Logger log = LoggingManager.getLoggerForClass();
private static final String NEW_LINE = "\n"; // $NON-NLS-1$
private static final String[] headersToRemove;
// Allow list of headers to be overridden
private static final String PROXY_HEADERS_REMOVE = "proxy.headers.remove"; // $NON-NLS-1$
private static final String PROXY_HEADERS_REMOVE_DEFAULT = "If-Modified-Since"; // $NON-NLS-1$
private static final String PROXY_HEADERS_REMOVE_SEPARATOR = ","; // $NON-NLS-1$
static {
String removeList = JMeterUtils.getPropDefault(PROXY_HEADERS_REMOVE,PROXY_HEADERS_REMOVE_DEFAULT);
headersToRemove = JOrphanUtils.split(removeList,PROXY_HEADERS_REMOVE_SEPARATOR);
log.info("Proxy will remove the headers: "+removeList);
}
/** Socket to client. */
private Socket clientSocket = null;
@ -180,7 +197,11 @@ public class Proxy extends Thread {
* We don't want to store any cookies in the generated test plan
*/
headers.removeHeaderNamed("cookie");// Always remove cookies // $NON-NLS-1$
headers.removeHeaderNamed("Authorization");// Always remove cookies // $NON-NLS-1$
headers.removeHeaderNamed("Authorization");// Always remove authorization // $NON-NLS-1$
// Remove additional headers
for(int i=0; i < headersToRemove.length; i++){
headers.removeHeaderNamed(headersToRemove[i]);
}
} catch (UnknownHostException uhe) {
log.warn("Server Not Found.", uhe);
writeErrorToClient(HttpReplyHdr.formServerNotFound());

View File

@ -40,6 +40,8 @@ Also user-written command files may need to be adjusted (the ones supplied with
<br></br>
To revert to the earlier behaviour, define the JMeter property: server.rmi.create=false.
</li>
<li>The Proxy server removes If-Modified-Since headers from generated Header Managers.
To revert to the previous behaviour, define the property proxy.headers.remove with no value</li>
</ul>
<h4>Bug fixes</h4>
@ -85,6 +87,8 @@ To revert to the earlier behaviour, define the JMeter property: server.rmi.creat
<li>Bug 43678 - Handle META tag http-equiv charset</li>
<li>Bug 42555 - [I18N] Proposed corrections for the french translation</li>
<li>Bug 43727 - Test Action does not support variables or functions</li>
<li>The Proxy server removes If-Modified-Since headers from generated Header Managers by default.
To change the list of removed headers, define the property proxy.headers.remove as a comma-separated list of headers to remove</li>
</ul>
<h4>Non-functional Improvements</h4>

View File

@ -3508,7 +3508,13 @@ Add menu (Add --> Non-Test Elements --> HTTP Proxy Server).</p>
If you are using grouping, please ensure that you leave the required gap between clicks.
</property>
<!-- TODO:property name="Group Separation Interval">Inactivity time between two requests needed to consider them in two separate groups.</property-->
<property name="Capture HTTP Headers" required="Yes">Should headers be added to the plan?</property>
<property name="Capture HTTP Headers" required="Yes">Should headers be added to the plan?
If specified, a Header Manager will be added to each HTTP Sampler.
The Proxy server always removes Cookie and Authorization headers from the generated Header Managers.
By default it also removes If-Modified-Since headers.
To change which additional headers are removed, define the JMeter property <b>proxy.headers.remove</b>
as a comma-separated list of headers.
</property>
<property name="Add Assertions" required="Yes">Add a blank assertion to each sampler?</property>
<property name="Regex Matching" required="Yes">Use Regex Matching when replacing variables?</property>
<property name="Type" required="Yes">Which type of sampler to generate (the Java default or HTTPClient)</property>