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

fix header map trie for large char #225

Merged
merged 1 commit into from
Nov 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions source/common/http/header_map_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ HeaderMapImpl::StaticLookupTable::StaticLookupTable() {

void HeaderMapImpl::StaticLookupTable::add(const char* key, StaticLookupEntry::EntryCb cb) {
StaticLookupEntry* current = &root_;
while (*key) {
if (!current->entries_[*key]) {
current->entries_[*key].reset(new StaticLookupEntry());
while (uint8_t c = *key) {
if (!current->entries_[c]) {
current->entries_[c].reset(new StaticLookupEntry());
}

current = current->entries_[*key].get();
current = current->entries_[c].get();
key++;
}

Expand All @@ -221,7 +221,7 @@ void HeaderMapImpl::StaticLookupTable::add(const char* key, StaticLookupEntry::E
HeaderMapImpl::StaticLookupEntry::EntryCb
HeaderMapImpl::StaticLookupTable::find(const char* key) const {
const StaticLookupEntry* current = &root_;
while (char c = *key) {
while (uint8_t c = *key) {
current = current->entries_[c].get();
if (current) {
key++;
Expand Down
8 changes: 8 additions & 0 deletions test/common/http/header_map_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,12 @@ TEST(HeaderMapImplTest, Equality) {
EXPECT_FALSE(headers1 == headers2);
}

TEST(HeaderMapImplTest, LargeCharInHeader) {
HeaderMapImpl headers;
LowerCaseString static_key("\x90hello");
std::string static_value("value");
headers.addStatic(static_key, static_value);
EXPECT_STREQ("value", headers.get(static_key)->value().c_str());
}

} // Http