Skip to content

Add --form flag for multipart/form-data uploads - #129

Open
ChrisJr404 wants to merge 1 commit into
codesenberg:masterfrom
ChrisJr404:form-multipart
Open

ChrisJr404 wants to merge 1 commit into
codesenberg:masterfrom
ChrisJr404:form-multipart

Conversation

@ChrisJr404

Copy link
Copy Markdown

This adds a --form/-F flag so bombardier can send multipart/form-data the way curl -F does, which is what #99 asked for.

You give it name=value for a plain field or name=@path to attach a file (the part filename is the base of the path). bombardier builds the body once with mime/multipart and sets Content-Type to multipart/form-data with the boundary it generates, so you don't have to craft the boundary or the body by hand anymore. If you pass your own Content-Type header it's left alone.

--form can be repeated and it conflicts with --body/--body-file (you get the existing "provided twice" error), and it's rejected for methods that can't carry a body.

Quick example:

bombardier -c 1 -n 1 -m POST -F "comment=hello" -F "file=@report.pdf" http://localhost:8080/upload

Tests: unit tests for the body builder (round-tripped through multipart.Reader) and its error cases, an end to end test that runs across all three clients and checks the server parses the field and file back, a missing-file case, plus the validation cases in the config test. go test ./..., -race, and go vet are clean (the two rate-limiter timing tests are flaky on my machine regardless of this change).

Closes #99.

curl style -F for building a multipart body, name=value for a plain
field and name=@file to attach a file. bombardier assembles the body and
sets Content-Type with the auto generated boundary, so you no longer have
to craft the boundary by hand. Closes codesenberg#99.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auto calculated boundary in large file uploading in asp.net core and testing with bombardier

1 participant