Add --form flag for multipart/form-data uploads - #129
Open
ChrisJr404 wants to merge 1 commit into
Open
ChrisJr404 wants to merge 1 commit into
ChrisJr404 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a
--form/-Fflag so bombardier can sendmultipart/form-datathe waycurl -Fdoes, which is what #99 asked for.You give it
name=valuefor a plain field orname=@pathto attach a file (the part filename is the base of the path). bombardier builds the body once withmime/multipartand setsContent-Typetomultipart/form-datawith the boundary it generates, so you don't have to craft the boundary or the body by hand anymore. If you pass your ownContent-Typeheader it's left alone.--formcan 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:
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, andgo vetare clean (the two rate-limiter timing tests are flaky on my machine regardless of this change).Closes #99.