Author: sebb
Date: Fri Nov 16 16:10:55 2007
New Revision: 595879
URL: http://svn.apache.org/viewvc?rev=595879&view=rev
Log:
Better error handling
Don't parse non-text files for form data
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java?rev=595879&r1=595878&r2=595879&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
Fri Nov 16 16:10:55 2007
@@ -28,6 +28,7 @@
import java.net.URL;
import java.util.Map;
+import org.apache.commons.httpclient.HttpConstants;
import org.apache.jmeter.protocol.http.control.HeaderManager;
import org.apache.jmeter.protocol.http.parser.HTMLParseException;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
@@ -196,9 +197,15 @@
} catch (UnknownHostException uhe) {
log.warn("Server Not Found.", uhe);
writeErrorToClient(HttpReplyHdr.formServerNotFound());
+ result = generateErrorResult(result, uhe); // Generate
result (if nec.) and populate it
+ } catch (IllegalArgumentException e) {
+ log.error("Not implemented (probably used https)", e);
+ writeErrorToClient(HttpReplyHdr.formNotImplemented());
+ result = generateErrorResult(result, e); // Generate
result (if nec.) and populate it
} catch (Exception e) {
- log.error("", e);
+ log.error("Exception when processing sample", e);
writeErrorToClient(HttpReplyHdr.formTimeout());
+ result = generateErrorResult(result, e); // Generate
result (if nec.) and populate it
} finally {
if (log.isDebugEnabled()) {
log.debug("Will deliver sample " +
sampler.getName());
@@ -224,6 +231,15 @@
}
}
+ private SampleResult generateErrorResult(SampleResult result, Exception
e) {
+ if (result == null) {
+ result = new SampleResult();
+ result.setSampleLabel("Sample failed");
+ }
+ result.setResponseMessage(e.getMessage());
+ return result;
+ }
+
/**
* Write output to the output stream, then flush and close the stream.
*
@@ -347,6 +363,9 @@
*/
private void addFormEncodings(SampleResult result, String pageEncoding) {
FormCharSetFinder finder = new FormCharSetFinder();
+ if (!result.getContentType().startsWith("text/")){ // TODO perhaps
make more specific than this?
+ return; // no point parsing anything else, e.g. GIF ...
+ }
try {
finder.addFormActionsAndCharSet(result.getResponseDataAsString(),
formEncodings, pageEncoding);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]