The content of posted files can depend on thread number, counters, parsed content etc... in some application (real-life situation requested by Ananda)
Created attachment 4211 [details] Patch against 18/12/2002 cvs, made from src directory
Attached patch adds new checkbox to HTTPSampler GUI: "Evaluate variables in file". If it's unchecked, everything goes without changes: when sampling, the uploaded file is opened and sent without thinking. If it's checked, when populating TestElements the file is read and treated as ordinary string property of TestElement. The advantage is that any variables existing in the file are expanded. But there is drawback: content of the file is written also in scenario file. The user should not bother, because the file is read when starting the test. When sampling evaluated content of the file is sent rather than original file.
This would be nice patch to include in next release. This was an issue I just encountered as well. If one doesn't actually need to post a file, then workaround is to paste the content into the value field of name/value pair section for HTTP sampler, can leave name field blank (for cases like making REST API call rather than form submission). But the unfortunate part is the UI for the name/value pair section sucks for long input strings, as it isn't resizable to be multi-line, so usable but not readable. That's where this bug/issue fix comes in nicely as you can put the data in text file that's easier to read and POST than via the form fields. Alternative fix in my case is make the form fields resizable and multiline supported.
*** Bug 36694 has been marked as a duplicate of this bug. ***
*** Bug 43850 has been marked as a duplicate of this bug. ***
Has this been incorporated or any plans to incorporate this (substitution of variables in POST data provided as file)?
The patch has not been incorporated, as it has some disadvantages. Also, the HTTP Sampler GUI has been enhanced to include a raw post body (will be in 2.6, due very soon).
Thanks a lot. Took the ApacheJMeter_http.jar from the last nightly build and used the raw POST with random variable - it worked great & solved my urgent purpose.
Could also be closed as with RAW POST Body it is now much more user friendly. Replacing within a file may also incur performance issues so not sure it is a good idea.
Closing as with RAW Body it is now much more user friendly. Replacing within a file may also incur performance issues so not sure it is a good idea.
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/996