Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http/client: add post() method helper #16718

Merged
merged 5 commits into from
Feb 27, 2024
Merged

http/client: add post() method helper #16718

merged 5 commits into from
Feb 27, 2024

Conversation

dotnwat
Copy link
Member

@dotnwat dotnwat commented Feb 26, 2024

Adds a http::client::post method which handles preparation of a post request as a convenience for the metrics reporter which is switched over to use this method.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.3.x
  • v23.2.x
  • v23.1.x

Release Notes

  • none

The iobuf already exists in memory and can be used directly as the body
for the http request.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
@dotnwat
Copy link
Member Author

dotnwat commented Feb 26, 2024

/ci-repeat 1

@vbotbuildovich
Copy link
Collaborator

new failures in https://buildkite.com/redpanda/redpanda/builds/45365#018de81e-602e-4fc2-a322-7c245141bc21:

"rptest.tests.leadership_transfer_test.MultiTopicAutomaticLeadershipBalancingTest.test_topic_aware_rebalance"

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
When requests are made without a host header field then one is
automatically added using the host/port from the transport config.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
@dotnwat
Copy link
Member Author

dotnwat commented Feb 27, 2024

/ci-repeat 1

@dotnwat dotnwat marked this pull request as ready for review February 27, 2024 06:39
@dotnwat dotnwat requested review from Lazin, abhijat, mmaslankaprv and andrwng and removed request for Lazin February 27, 2024 06:39
Comment on lines -165 to -175
http::client::request_header
metrics_reporter::make_header(const iobuf& buffer) {
http::client::request_header header;
header.method(boost::beast::http::verb::post);
header.target(std::string(_address.path));
header.insert(
boost::beast::http::field::content_length,
fmt::format("{}", buffer.size_bytes()));
header.insert(
boost::beast::http::field::host,
fmt::format("{}:{}", _address.host, _address.port));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice simplification -- glad callers won't have to deal with headers anymore.

@dotnwat dotnwat merged commit cbec25a into redpanda-data:dev Feb 27, 2024
17 checks passed
@dotnwat
Copy link
Member Author

dotnwat commented Feb 27, 2024

cc @Lazin can you take a look?

Copy link
Contributor

@Lazin Lazin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants