client: add --request-body-file to send a file's bytes as the request body - #1601
Open
bpalermo wants to merge 1 commit into
Open
client: add --request-body-file to send a file's bytes as the request body#1601bpalermo wants to merge 1 commit into
bpalermo wants to merge 1 commit into
Conversation
… body
Nighthawk could only send a synthetic body ('a' repeated --request-body-size
times) or, through a request source plugin, a UTF-8 json_body string. Add
--request-body-file, which reads the whole file and sends its bytes
verbatim on every request (binary safe), carried over the gRPC service API
in the new RequestOptions.request_body bytes field. Content-Length is set
from the body size; no Content-Type is assumed, supply one with
--request-header. Mutually exclusive with --request-body-size.
StaticRequestSourceImpl gains an optional body so the static request source
can yield it; the plugin and remote request sources are unchanged.
Signed-off-by: Bruno Palermo <[email protected]>
This was referenced Sep 7, 2026
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.
Description
This PR is related to #1608
Nighthawk can only send a synthetic body (
'a'repeated--request-body-sizetimes) or, through a request source plugin, ajson_body, which is a proto3stringand therefore must be UTF-8. That rules out sending an arbitrary payload such as a serialized protobuf.This adds
--request-body-file <path>: the file's bytes are sent verbatim on every request (binary safe). Over the gRPC service API the body travels in the newRequestOptions.request_body(bytes) field.Content-Lengthis set from the body size; noContent-Typeis assumed, pass one with--request-header.--request-body-sizebehavior is unchanged, and the two are mutually exclusive.Notes for Reviewers
OptionsImplreads the file at parse time (size cap, clear errors for unreadable files);StaticRequestSourceImplgains an optional body;RequestSourceFactoryImplpasses it through. Plugin and remote request sources are unchanged.//test:options_test(verbatim binary content and proto round trip, missing file, mutual exclusion),//test:factories_test(body,Content-Length, noContent-Type),test/integration/test_request_body_file.py(full run posting a binary file to the test server). README usage regenerated; version history updated.