Skip to content

client: add --request-body-file to send a file's bytes as the request body - #1601

Open
bpalermo wants to merge 1 commit into
envoyproxy:mainfrom
bpalermo:up/request-body-file
Open

client: add --request-body-file to send a file's bytes as the request body#1601
bpalermo wants to merge 1 commit into
envoyproxy:mainfrom
bpalermo:up/request-body-file

Conversation

@bpalermo

@bpalermo bpalermo commented Sep 7, 2026

Copy link
Copy Markdown

Description

This PR is related to #1608

Nighthawk can only send a synthetic body ('a' repeated --request-body-size times) or, through a request source plugin, a json_body, which is a proto3 string and 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 new RequestOptions.request_body (bytes) field. Content-Length is set from the body size; no Content-Type is assumed, pass one with --request-header. --request-body-size behavior is unchanged, and the two are mutually exclusive.

Notes for Reviewers

  • OptionsImpl reads the file at parse time (size cap, clear errors for unreadable files); StaticRequestSourceImpl gains an optional body; RequestSourceFactoryImpl passes it through. Plugin and remote request sources are unchanged.
  • Testing: //test:options_test (verbatim binary content and proto round trip, missing file, mutual exclusion), //test:factories_test (body, Content-Length, no Content-Type), test/integration/test_request_body_file.py (full run posting a binary file to the test server). README usage regenerated; version history updated.
  • Prerequisite for client: add --grpc-mode unary for gRPC load with grpc-status scoring #1602 (gRPC unary mode, Support gRPC #24).

… 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]>
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.

1 participant