support multipart POST for apachebench?

点点圈 提交于 2019-12-03 09:55:18

问题


I want to use apachebench (ab) to test file upload performance. I have read the manual and can't find a way to achieve my goal.

My goal is try to upload a file by a HTTP Request with POST method and multipart/form-data format.

The ab support "-p POST-FILE", but I only can find the format key=value&key2=value2

What the post data I want to send is

Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryuUlX4554LPBjInc5

------WebKitFormBoundaryuUlX4554LPBjInc5 Content-Disposition: form-data; name="file"; filename="411c40d9.jpg" Content-Type: image/jpeg

XXXXXXXXXXXXXXX (IMAGE DATA) YYYYYYYYYYYYYYYYYYYYYYYYYYYYY

I googled for a while and can't find any related article or way to achieve that. I use cURL and it works fine, but I want to do stress testing. So I need use ab to achieve that goal.

Any suggestions?


回答1:


This may be very late but might help others who were searching for the same thing...

$ ab -c 5 -n 5 -v 4 -p example_post.txt -T "multipart/form-data; boundary=miuxupsktcqtriloonfbdudrgtawascl" http://yourapplication.local/upload/

Credit to this guy.



来源:https://stackoverflow.com/questions/4317400/support-multipart-post-for-apachebench

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!