-
Notifications
You must be signed in to change notification settings - Fork 84
test: use TestRequestHeaderMapImpl for building custom headers #2455
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
Changes from all commits
0f08b73
bbb24fd
d7f31d3
3ac0389
fe86f65
defc626
a398b4e
fb2276d
9e72e3c
464f0e6
2703f3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,13 @@ | ||
| #include "test/common/integration/base_client_integration_test.h" | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "test/common/http/common.h" | ||
|
|
||
| #include "gtest/gtest.h" | ||
| #include "library/cc/bridge_utility.h" | ||
| #include "library/common/config/internal.h" | ||
| #include "library/common/http/header_utility.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace { | ||
|
|
@@ -89,15 +95,37 @@ void BaseClientIntegrationTest::initialize() { | |
|
|
||
| stream_ = (*stream_prototype_).start(explicit_flow_control_); | ||
| std::string host(fake_upstreams_[0]->localAddress()->asStringView()); | ||
| Platform::RequestHeadersBuilder builder(Platform::RequestMethod::GET, scheme_, host, "/"); | ||
| for (auto& entry : custom_headers_) { | ||
| auto values = {entry.second}; | ||
| builder.set(entry.first, values); | ||
| } | ||
| HttpTestUtility::addDefaultHeaders(default_request_headers_); | ||
| default_request_headers_.setHost(fake_upstreams_[0]->localAddress()->asStringView()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is setHost on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, thanks for clarifying. The |
||
| } | ||
|
|
||
| std::shared_ptr<Platform::RequestHeaders> BaseClientIntegrationTest::envoyToMobileHeaders( | ||
alyssawilk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const Http::TestRequestHeaderMapImpl& request_headers) { | ||
|
|
||
| Platform::RequestHeadersBuilder builder( | ||
| Platform::RequestMethod::GET, | ||
| std::string(default_request_headers_.Scheme()->value().getStringView()), | ||
| std::string(default_request_headers_.Host()->value().getStringView()), | ||
| std::string(default_request_headers_.Path()->value().getStringView())); | ||
| if (upstreamProtocol() == Http::CodecType::HTTP2) { | ||
| builder.addUpstreamHttpProtocol(Platform::UpstreamHttpProtocol::HTTP2); | ||
| } | ||
| default_request_headers_ = std::make_shared<Platform::RequestHeaders>(builder.build()); | ||
|
|
||
| request_headers.iterate( | ||
| [&request_headers, &builder](const Http::HeaderEntry& header) -> Http::HeaderMap::Iterate { | ||
| std::string key = std::string(header.key().getStringView()); | ||
| if (request_headers.formatter().has_value()) { | ||
| const Envoy::Http::StatefulHeaderKeyFormatter& formatter = | ||
| request_headers.formatter().value(); | ||
| key = formatter.format(key); | ||
| } | ||
| auto value = std::vector<std::string>(); | ||
| value.push_back(std::string(header.value().getStringView())); | ||
| builder.set(key, value); | ||
| return Http::HeaderMap::Iterate::Continue; | ||
| }); | ||
|
|
||
| return std::make_shared<Platform::RequestHeaders>(builder.build()); | ||
| } | ||
|
|
||
| void BaseClientIntegrationTest::threadRoutine(absl::Notification& engine_running) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The edits to this file aren't strictly part of this diff. I just noticed that the
toEnvoyHeadersfunction has better parameter names in itsheader_utility.hfile, figured I'd fix the mismatch.