mstover1 2002/08/20 07:23:42
Modified: src/protocol/http/org/apache/jmeter/protocol/http/sampler
HTTPSampler.java
Log:
Fixing HTTPSampler's dealing with error responses from the server, such as 404, and
500 errors.
Revision Changes Path
1.5 +18 -5
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HTTPSampler.java 14 Aug 2002 02:52:19 -0000 1.4
+++ HTTPSampler.java 20 Aug 2002 14:23:42 -0000 1.5
@@ -634,7 +634,15 @@
protected byte[] readResponse(HttpURLConnection conn) throws IOException
{
byte[] buffer = new byte[4096];
- BufferedInputStream in = new
BufferedInputStream(conn.getInputStream());
+ BufferedInputStream in;
+ try
+ {
+ in = new BufferedInputStream(conn.getInputStream());
+ }
+ catch(Exception e)
+ {
+ in = new BufferedInputStream(conn.getErrorStream());
+ }
java.io.ByteArrayOutputStream w = new ByteArrayOutputStream();
int x = 0;
while((x = in.read(buffer)) > -1)
@@ -922,8 +930,13 @@
}
catch(IOException ex)
{
- //ex.printStackTrace();
- res.setResponseData(ex.toString().getBytes());
+ ex.printStackTrace();
+ res.setDataType(res.TEXT);
+ try {
+ res.setResponseData(readResponse(conn));
+ } catch (IOException e) {
+ res.setResponseData(ex.toString().getBytes());
+ }
res.setResponseCode(NON_HTTP_RESPONSE_CODE);
res.setResponseMessage(NON_HTTP_RESPONSE_MESSAGE);
res.setTime(System.currentTimeMillis() - time);
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>