-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[thrift_proxy] Replace local HeaderMap with Http::HeaderMap[Impl] #4169
Merged
zuercher
merged 10 commits into
envoyproxy:master
from
turbinelabs:brirams/#5555/thrift_proxy/use_http_header_impl
Aug 17, 2018
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ee0c291
replace ThriftProxy::HeaderMap with Http::HeaderMap and Http::HeaderM…
brirams e5cdb3b
stop using addReference and let clients of MessageMetadata decide how…
brirams a55e68c
use the HeaderMap interface correctly in tests
brirams 24952b1
update header_transport_impl to use new http headers
brirams 46eaad6
format header_transport_impl correctly
brirams 2164b60
use len
brirams 29af572
clean up after ourselves
brirams b01a6f7
learn that the formatter should just never be skipped
brirams 436ce7c
use a shared_ptr instead
brirams 790a81d
construct LowerCaseString straight away, const it up
brirams File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,7 +146,7 @@ bool HeaderTransportImpl::decodeFrameStart(Buffer::Instance& buffer, MessageMeta | |
while (num_headers-- > 0) { | ||
std::string key = drainVarString(buffer, header_size, "header key"); | ||
std::string value = drainVarString(buffer, header_size, "header value"); | ||
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. nit: should key/value be consts? |
||
metadata.addHeader(Header(key, value)); | ||
metadata.headers().addCopy(Http::LowerCaseString(key), value); | ||
} | ||
} | ||
|
||
|
@@ -172,7 +172,7 @@ void HeaderTransportImpl::encodeFrame(Buffer::Instance& buffer, const MessageMet | |
throw EnvoyException(fmt::format("invalid thrift header transport message size {}", msg_size)); | ||
} | ||
|
||
const HeaderMap& headers = metadata.headers(); | ||
const Http::HeaderMap& headers = metadata.headers(); | ||
if (headers.size() > MaxHeadersSize / 2) { | ||
// Each header takes a minimum of 2 bytes, yielding this limit. | ||
throw EnvoyException( | ||
|
@@ -205,10 +205,14 @@ void HeaderTransportImpl::encodeFrame(Buffer::Instance& buffer, const MessageMet | |
// Num headers | ||
BufferHelper::writeVarIntI32(header_buffer, static_cast<int32_t>(headers.size())); | ||
|
||
for (const Header& header : headers) { | ||
writeVarString(header_buffer, header.key()); | ||
writeVarString(header_buffer, header.value()); | ||
} | ||
headers.iterate( | ||
[](const Http::HeaderEntry& header, void* context) -> Http::HeaderMap::Iterate { | ||
Buffer::Instance* hb = static_cast<Buffer::Instance*>(context); | ||
writeVarString(*hb, header.key().getStringView()); | ||
writeVarString(*hb, header.value().getStringView()); | ||
return Http::HeaderMap::Iterate::Continue; | ||
}, | ||
&header_buffer); | ||
} | ||
|
||
uint64_t header_size = header_buffer.length(); | ||
|
@@ -286,7 +290,7 @@ std::string HeaderTransportImpl::drainVarString(Buffer::Instance& buffer, int32_ | |
return value; | ||
} | ||
|
||
void HeaderTransportImpl::writeVarString(Buffer::Instance& buffer, const std::string& str) { | ||
void HeaderTransportImpl::writeVarString(Buffer::Instance& buffer, const absl::string_view str) { | ||
std::string::size_type len = str.length(); | ||
if (len > static_cast<uint32_t>(std::numeric_limits<int16_t>::max())) { | ||
throw EnvoyException(fmt::format("header string too long: {}", len)); | ||
|
@@ -296,7 +300,7 @@ void HeaderTransportImpl::writeVarString(Buffer::Instance& buffer, const std::st | |
if (len == 0) { | ||
return; | ||
} | ||
buffer.add(str); | ||
buffer.add(str.data(), len); | ||
} | ||
|
||
class HeaderTransportConfigFactory : public TransportFactoryBase<HeaderTransportImpl> { | ||
|
This file contains 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
47 changes: 0 additions & 47 deletions
47
source/extensions/filters/network/thrift_proxy/metadata.cc
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
nit: couldn't key be constructed here as a
LowerCaseString
?