[HTTP raw request] upload file questions

347 views
Skip to first unread message

kto...@issart.com

unread,
Aug 7, 2018, 2:19:29 AM8/7/18
to jmeter-plugins
Please, help me to understand file upload process using HTTP raw request sampler.

I'm trying to upload a file via HTTP POST request. First, I manually uploaded a file to a resource and recorded actions by Wireshark. Then, I copied request data from Wireshark to an HTTP raw request sampler. After running my script I get "408 Request Timeout" response. What am I doing wrong?

Request data:
POST /test HTTP/1.1
Connection: keep-alive
Content-Length: 622
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarybFM3GLZw0xYxeZZn

------WebKitFormBoundarybFM3GLZw0xYxeZZn
Content-Disposition: form-data; name="do"

test
------WebKitFormBoundarybFM3GLZw0xYxeZZn
Content-Disposition: form-data; name="subdo"

file_upload
------WebKitFormBoundarybFM3GLZw0xYxeZZn
Content-Disposition: form-data; name="file_upload"; filename="Untitled.png"
Content-Type: image/png

PNG


IHDRwSÞsRGB®ÎégAMA± üa pHYsÃÃÇo¨d IDATWcøÿÿ?þþ§5IEND®B`
------WebKitFormBoundarybFM3GLZw0xYxeZZn
Content-Disposition: form-data; name="http_submit"

Start HTTP upload
------WebKitFormBoundarybFM3GLZw0xYxeZZn--


Additional question: there is a "Data file path" bar in an HTTP raw request sampler. As I understand, binary value of a file specified, added directly after request data. Right? May I use "Data file path" to specify a path to a file in example above?

Andrey Pokhilko

unread,
Aug 7, 2018, 2:58:04 AM8/7/18
to jmeter-...@googlegroups.com

Hi,

Request timeout means that most likely your request does not contain enough data, or not all of \r\n terminators are correct. The len of body of request has to match Content-Length value strictly. JMeter UI might be tricky to satisfy all these requirements, that's why "Data file path" is there. I usually put all headers into UI, while all body is inside external file. Thus, I can make sure the file size strictly matches content-length. But it does not solve problem of "don't forget \r\n between headers and body", which is easy to overlook because it is whitespace.

Andrey Pokhilko

07.08.2018 09:19, kto...@issart.com пишет:
--
You received this message because you are subscribed to the Google Groups "jmeter-plugins" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jmeter-plugin...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

kto...@issart.com

unread,
Aug 9, 2018, 8:03:10 AM8/9/18
to jmeter-plugins
Thanks, Andrey. I really do appreciate your work!

вторник, 7 августа 2018 г., 13:58:04 UTC+7 пользователь Andrey Pokhilko написал:

Colin McCormack

unread,
Aug 25, 2021, 10:29:05 AM8/25/21
to jmeter-plugins
i'm pre-building the request with ${variable} in my pre-built requests - how do i get the Content-Length - do i have to do a dry-run a pre-pre-built jsr223 req to save the Content-Length then add that?

DT

unread,
Aug 25, 2021, 11:26:01 AM8/25/21
to jmeter-plugins
Content-Length is basically the size of your request in bytes in case of POST

So just calculate your variable size in bytes and that would be it, if you want to do this dynamically as well you can use __groovy() function like:

${__groovy(vars.get('variable').length(),)}

Colin McCormack

unread,
Aug 25, 2021, 11:28:10 AM8/25/21
to jmeter-plugins
ah great - this works for me thanks - but now i get a 200 back and nothing in the server, certainly no response back in jmeter - must be something on the wire or server blocks
Reply all
Reply to author
Forward
0 new messages