Ooops replied to wrong email ... Re: Header Manager bug? instead of Diff
between HTTPClient + URLConn...
Hi,
Thought this might be of use to someone else trying to do the same thing
with low Java skills ;). Things I had to change to get Body to be sent and
a New Method called REPORT to be added...
Changes to HTTPSampler2.java
A new sampler class was created called XXXHTTPSampler2 this class was made
using modifications to the HTTPSampler2 class. The modifications are:
Add extra import lines:
import java.util.Arrays;
import java.util.Collections;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.methods.XXXReportMethod;
Add Static definitions (not really needed but matches the standard)
//RR Added for Body
public final static String BODY = "BODY"; // $NON-NLS-1$
//RR Added to allow Report Method which is matched with PUT
public final static String REPORT = "REPORT"; // $NON-NLS-1$
Add Report to String [ ] METHODS in declaration:
// RR Added to get Report in
public final static List METHODLIST =
Collections.unmodifiableList(Arrays.asList(METHODS)
Add REPORT to the if else calls in the XXXHTTPSampleResult Method
} else if (method.equals(REPORT)){
httpMethod = new XXXReportMethod(urlStr);
}else if (method.equals(REPORT)) {
setReportHeaders((XXXReportMethod) httpMethod);
Add the body to the Message being sent in the PUT Method.
//RR Added to Send Body With Put Message
if ((filename != null) && (getBody()!=null))
{
put.setRequestEntity(new StringRequestEntity(getBody(),null,null));
}
Duplicated the PUT calls for the REPORT method.
private void setReportHeaders(XXXReportMethod report)
throws IOException
{
String filename = getFilename();
if ((filename != null) && (filename.trim().length() > 0))
{
RequestEntity requestEntity = new InputStreamRequestEntity(
new FileInputStream(filename),getMimetype());
report.setRequestEntity(requestEntity);
}
//RR Added to Send Body With Put Report
if ((filename != null) && (getBody()!=null))
{
report.setRequestEntity(new StringRequestEntity(getBody(),null,null));
}
}
Add set & get methods
//RR Added for Body
public void setBody (String value) {
setProperty(BODY, value);
}
RR Added for Body
public String getBody() {
return getPropertyAsString(BODY);
}
Need to add the new METHODLIST call so it uses our new METHODLIST
// RR Added to get Method in
public static String[] getValidMethodsAsArray(){
return (String[]) METHODLIST.toArray(new String[0]);
Changes for XXXHttpTestSampleGui2.java
This file is a straight copy of the standard HttpTestSampleGui2 class with
some changes to use the modified XXXHTTPSampler2, XXXMultipartUrlConfigGui.
getImages.setSelected(((XXXHTTPSampler2) element).isImageParser());
isMon.setSelected(((XXXHTTPSampler2) element).isMonitor());
XXXHTTPSampler2 sampler = new XXXHTTPSampler2();
return super.getStaticLabel() + " HTTPClient" + "XXX"; // $NON-NLS-1$
((XXXHTTPSampler2) sampler).setImageParser(true);
.
sampler.removeProperty(XXXHTTPSampler2.IMAGE_PARSER);// TODO - why?
((XXXHTTPSampler2) sampler).setMonitor(isMon.isSelected());
urlConfigGui = new XXXMultipartUrlConfigGui();
XXXMultipartUrlConfigGui
FROM
public class MultipartUrlConfigGui extends UrlConfigGui implements
ActionListener {
TO
public class XXXMultipartUrlConfigGui extends XXXUrlConfigGui implements
ActionListener {
FROM
public MultipartUrlConfigGui() {
TO
public XXXMultipartUrlConfigGui() {
Changes for XXXReportMethod
package org.apache.commons.httpclient.methods;
/*
* Taken from Jakarta Package Put Method
*/
public class XXXReportMethod extends EntityEnclosingMethod {
public XXXReportMethod() {
super();
}
public XXXReportMethod(String uri) {
super(uri);
}
public String getName() {
return "REPORT";
}
}
Changes for XXXUrlConfigGui
FROM
public class MultipartUrlConfigGui extends UrlConfigGui implements
ActionListener {
TO
public class XXXMultipartUrlConfigGui extends XXXUrlConfigGui implements
ActionListener {
FROM
public MultipartUrlConfigGui() {
TO
public XXXMultipartUrlConfigGui() {
Please note the above probably does not stick to standards and I have not
used it with lots and lots of threads yet. But the basics work...
Cheers
Reza
From: sebb <[EMAIL PROTECTED]>
Reply-To: "JMeter Users List" <jmeter-user@jakarta.apache.org>
To: "JMeter Users List" <jmeter-user@jakarta.apache.org>
Subject: Re: Header Manager bug?
Date: Wed, 4 Oct 2006 13:58:56 +0100
There's already a similar bug report; I suggest you update it with
your information if necessary.
On 03/10/06, R R <[EMAIL PROTECTED]> wrote:
Hi,
Not sure if this is intended behaviour if not I will raise a bugzilla.
If you copy the Header Manager to another sampler in another thread group
and then change a value in the header (not the header name, so change the
value of Depth from 1 to 2 for example). It will change the value for all
of
the Header Managers not just the one that was changed. I assume this is
as
they are referring to the same object.
A workaround is to not use the copy and past but to either create a new
header manager in the thread group or delete the old value and then
re-insert it.
Intended?
R
_________________________________________________________________
Windows Live Messenger has arrived. Click here to download it for free!
http://imagine-msn.com/messenger/launch80/?locale=en-gb
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
Windows Live Messenger has arrived. Click here to download it for free!
http://imagine-msn.com/messenger/launch80/?locale=en-gb
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
Windows Live Messenger has arrived. Click here to download it for free!
http://imagine-msn.com/messenger/launch80/?locale=en-gb
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]