I am trying to emulate POST for stress testing with JMeter.
The "standard" POST (done by browser or curl) looks like:
POST /foo/boo HTTP/1.1
User-Agent: curl/7.35.0
Host: localhost:4000
Accept: */*
Content-Length: 8376
Content-Type: multipart/form-data; boundary=------------------------9dec6d453f478def
--------------------------9dec6d453f478def
Content-Disposition: form-data; name="filedata"; filename="plan.jmx"
Content-Type: application/octet-stream
....
However the request after jmeter lacks the filename attribute of the Content-Disposition section:
POST /feedback/1.0/attack/ HTTP/1.1
Connection: keep-alive
Content-Length: 8331
Content-Type: multipart/form-data; boundary=qO2U87_27QtEGliQMv6ZGjIe6PnfEh1TX-RHAhJ
Host: localhost:4000
User-Agent: Apache-HttpClient/4.3.3 (java 1.5)
--qO2U87_27QtEGliQMv6ZGjIe6PnfEh1TX-RHAhJ
Content-Disposition: form-data; name="filedata"
....
I looked at the XML and jmeter config looks like:
<elementProp name="HTTPsampler.Files" elementType="HTTPFileArgs">
<collectionProp name="HTTPFileArgs.files">
<elementProp name="/Users/alexey/Work/all-attacks.zip" elementType="HTTPFileArg">
<stringProp name="File.path">plan.jmx</stringProp>
<stringProp name="File.paramname">filedata</stringProp>
<stringProp name="File.mimetype"></stringProp>
</elementProp>
</collectionProp>
</elementProp>
What is the way of specifying the filename attribute of the Content-Disposition when using jmeter?
It should be as simple as:
Use multipart/form-data for POSTProvide full path to file and filedata as "Parameter Name"
HTTP Request

View Results Tree listener output

See Performance testing: Upload and Download Scenarios with Apache JMeter guide for comprehensive information on how to simulate file operations in your JMeter test.
If you want to add any header into your request then you can add by passing those values into Http Header Manager (it'll be a child element for Http request)
Content-Disposition: form-data; name="filedata"; filename="plan.jmx"
Here Pass Content-Disposition in Name filed of header manger and rest in value field (no need to pass : ). It'll add this header in your request.
Also, are you getting proper response while executing this request from Jmeter? If not, try to change the implementation to Java of Http Request
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With