Skip to content

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

Merged
eric846 merged 3 commits into
envoyproxy:mainfrom
bpalermo:up/request-body-file
Sep 17, 2026
Merged

eric846 merged 3 commits into
envoyproxy:mainfrom
bpalermo:up/request-body-file

Conversation

@bpalermo

@bpalermo bpalermo commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

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 <bruno.palermo@superbid.net>
eric846
eric846 previously approved these changes Sep 16, 2026
Keeps the branch mergeable after the Envoy bump to 82c182e, the
envoy_package additions and envoyproxy#1598 landing. The only conflict was the
version history changelist, where both sides add a bullet; both are
kept.

Signed-off-by: Bruno Palermo <bruno.palermo@superbid.net>
Second update in a row: envoyproxy#1599 landed while this branch was being brought
up to date. Conflicts were all "both sides added something in the same
place":

- toCommandLineOptionsInternal(): envoyproxy#1599 hoisted the request_body_size
  emission out of the request header loop, this branch added the
  request_body emission next to it. Both are kept; an explicitly emitted
  request_body_size of 0 does not trip the exclusivity check in
  validate(), which tests request_body_size_ > 0.
- options_test.cc and the version history changelist: both sides append
  their own test / bullet, both are kept.

Signed-off-by: Bruno Palermo <bruno.palermo@superbid.net>
@bpalermo
bpalermo requested a review from eric846 September 16, 2026 21:18
@bpalermo

Copy link
Copy Markdown
Contributor Author

@eric846 gentle ping after fixing conflicts 🙏 ?

@eric846
eric846 merged commit 403f977 into envoyproxy:main Sep 17, 2026
9 checks passed
@bpalermo
bpalermo deleted the up/request-body-file branch September 17, 2026 12:29
bpalermo added a commit to bpalermo/nighthawk that referenced this pull request Sep 17, 2026
Brings the branch up to date after envoyproxy#1601 landed. The only conflict was
the version history changelist, where both sides add a bullet; both are
kept. Pushing this also gives the tsan job a second run: the failure
eric846 saw was test_https_prefetching, which asserts 50 TLS connections
are established inside a 1 second run, and it failed because the counter
was absent rather than wrong, i.e. no connection completed in time.

Signed-off-by: Bruno Palermo <bruno.palermo@superbid.net>
bpalermo added a commit to bpalermo/nighthawk that referenced this pull request Sep 17, 2026
envoyproxy#1601 was squash merged, so main carries the --request-body-file change
as a single commit while this branch still carries its originals. Every
conflict was this branch's unary additions against main's post squash
text, with no hunk where main had content this branch lacked, so each
was resolved in favour of this branch. The version history changelist
keeps main's entries plus this branch's.

Signed-off-by: Bruno Palermo <b@palermo.dev>
bpalermo added a commit to bpalermo/nighthawk that referenced this pull request Sep 17, 2026
Brings in that branch's merge of upstream main, which resolves this
branch against main after envoyproxy#1601 was squash merged. No conflicts.

Signed-off-by: Bruno Palermo <b@palermo.dev>
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.

2 participants