DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43850>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43850

           Summary: allow passing of jmeter variables in post data
           Product: JMeter
           Version: 2.3
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: HTTP
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


I recently modified source code to enable me to insert variables into post data
quite easily actually. In HTTPSampler when sending post data and iterating
through the GUI arguments just changed the code to look something like this:

while (args.hasNext()) {
                HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
                
                int left = arg.getValue().indexOf("{");
                int right = arg.getValue().indexOf("}", left);
                
                String val = arg.getValue();
                if ((left != -1) && (right != -1)) {
                        // we may have a variable
                        String varName = arg.getValue().substring(left + 1, 
right);
                        val =
JMeterContextService.getContext().getVariables().get(varName);
                        // this variable isn't defined or this wasn't actually 
a variable
                        if (val == null)
                                val = arg.getValue();
                }
                
                parts[partNo++] = new StringPart(arg.getName(), val,
contentEncoding);
            }
This allows for a variable defined by JMeter to be inserted, particularly useful
for multiple threads needing different values in a URL and if the variable
doesn't exist it just keeps the value in.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to