You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by js...@apache.org on 2004/02/05 17:00:35 UTC
cvs commit: jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler HTTPSampler.java
jsalvata 2004/02/05 08:00:35
Modified: src/protocol/http/org/apache/jmeter/protocol/http/sampler
HTTPSampler.java
Log:
Removed pattern cache used to cache a single pattern.
Renamed a private method.
Support URL with spaces in Location: headers -- it's against
the standards but most browsers support it.
Revision Changes Path
1.81 +26 -13 jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
Index: HTTPSampler.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- HTTPSampler.java 15 Jan 2004 10:43:34 -0000 1.80
+++ HTTPSampler.java 5 Feb 2004 16:00:35 -0000 1.81
@@ -102,7 +102,8 @@
import org.apache.log.Logger;
-import org.apache.oro.text.PatternCacheLRU;
+import org.apache.oro.text.regex.MalformedPatternException;
+import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.Perl5Compiler;
import org.apache.oro.text.regex.Perl5Matcher;
import org.apache.oro.text.regex.StringSubstitution;
@@ -174,9 +175,8 @@
System.setProperty("javax.net.ssl.debug", "all");
}
- private static PatternCacheLRU patternCache=
- new PatternCacheLRU(1000, new Perl5Compiler());
-
+ private static Pattern pattern; // initialized by the constructor
+
private static ThreadLocal localMatcher= new ThreadLocal()
{
protected synchronized Object initialValue()
@@ -204,6 +204,19 @@
*/
public HTTPSampler()
{
+ try
+ {
+ pattern= new Perl5Compiler().compile(
+ " ",
+ Perl5Compiler.READ_ONLY_MASK
+ & Perl5Compiler.SINGLELINE_MASK);
+ }
+ catch (MalformedPatternException e)
+ {
+ log.error("Cant compile pattern.", e);
+ throw new Error(e.toString()); // programming error -- bail out
+ }
+
setArguments(new Arguments());
}
@@ -284,21 +297,18 @@
public void setEncodedPath(String path)
{
- path= encodePath(path);
+ path= encodeSpaces(path);
setProperty(ENCODED_PATH, path);
}
- private String encodePath(String path)
+ private String encodeSpaces(String path)
{
// TODO JDK1.4
// this seems to be equivalent to path.replaceAll(" ","%20");
path=
Util.substitute(
(Perl5Matcher)localMatcher.get(),
- patternCache.getPattern(
- " ",
- Perl5Compiler.READ_ONLY_MASK
- & Perl5Compiler.SINGLELINE_MASK),
+ pattern,
spaceSub,
path,
Util.SUBSTITUTE_ALL);
@@ -327,7 +337,7 @@
super.addProperty(
new StringProperty(
ENCODED_PATH,
- encodePath(prop.getStringValue())));
+ encodeSpaces(prop.getStringValue())));
}
}
@@ -1225,7 +1235,10 @@
int redirect;
for (redirect= 0; redirect < MAX_REDIRECTS; redirect++)
{
- String location= lastRes.getRedirectLocation();
+ String location= encodeSpaces(lastRes.getRedirectLocation());
+ // Browsers seem to tolerate Location headers with spaces,
+ // replacing them automatically with %20. We want to emulate
+ // this behaviour.
try
{
lastRes=
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org