Rename SpdyHeaderBlock to Http2HeaderBlock, with a using alias.
The goal is to rename SpdyHeaderBlock to Http2HeaderBlock, but performing that
rename globally in one CL would be rather large (cl/336384859). Instead, this
CL performs the rename just for the library and adds a using alias to allow the
global rename to be performed piecemeal. Thanks to ++birenroy@ for the idea!
As part of the alias addition, this CL also removes some forward declarations
of SpdyHeaderBlock in favor of #include-ing the corresponding header file. This
substitution is needed to prevent compilation errors like:
./third_party/quic/tools/quic_simple_server_backend.h:12:7: error: definition of type 'SpdyHeaderBlock' conflicts with type alias of the same name
class SpdyHeaderBlock;
^
./third_party/spdy/core/spdy_header_block.h:294:7: note: 'SpdyHeaderBlock' declared here
using SpdyHeaderBlock = Http2HeaderBlock;
PiperOrigin-RevId: 338091517
Change-Id: Ib1db825a7e7b6775f9da6b377fdd3321a6d204ce
diff --git a/quic/core/qpack/qpack_encoder.h b/quic/core/qpack/qpack_encoder.h
index c170e09..7b99a65 100644
--- a/quic/core/qpack/qpack_encoder.h
+++ b/quic/core/qpack/qpack_encoder.h
@@ -20,12 +20,7 @@
#include "net/third_party/quiche/src/quic/core/quic_types.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_exported_stats.h"
-
-namespace spdy {
-
-class SpdyHeaderBlock;
-
-} // namespace spdy
+#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h"
namespace quic {
diff --git a/quic/tools/quic_simple_server_backend.h b/quic/tools/quic_simple_server_backend.h
index 968ec66..3941784 100644
--- a/quic/tools/quic_simple_server_backend.h
+++ b/quic/tools/quic_simple_server_backend.h
@@ -7,10 +7,7 @@
#include "net/third_party/quiche/src/quic/core/quic_types.h"
#include "net/third_party/quiche/src/quic/tools/quic_backend_response.h"
-
-namespace spdy {
-class SpdyHeaderBlock;
-} // namespace spdy
+#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h"
namespace quic {
diff --git a/spdy/core/spdy_header_block.cc b/spdy/core/spdy_header_block.cc
index ebb7918..23dd999 100644
--- a/spdy/core/spdy_header_block.cc
+++ b/spdy/core/spdy_header_block.cc
@@ -38,23 +38,23 @@
} // namespace
-SpdyHeaderBlock::HeaderValue::HeaderValue(SpdyHeaderStorage* storage,
- absl::string_view key,
- absl::string_view initial_value)
+Http2HeaderBlock::HeaderValue::HeaderValue(SpdyHeaderStorage* storage,
+ absl::string_view key,
+ absl::string_view initial_value)
: storage_(storage),
fragments_({initial_value}),
pair_({key, {}}),
size_(initial_value.size()),
separator_size_(SeparatorForKey(key).size()) {}
-SpdyHeaderBlock::HeaderValue::HeaderValue(HeaderValue&& other)
+Http2HeaderBlock::HeaderValue::HeaderValue(HeaderValue&& other)
: storage_(other.storage_),
fragments_(std::move(other.fragments_)),
pair_(std::move(other.pair_)),
size_(other.size_),
separator_size_(other.separator_size_) {}
-SpdyHeaderBlock::HeaderValue& SpdyHeaderBlock::HeaderValue::operator=(
+Http2HeaderBlock::HeaderValue& Http2HeaderBlock::HeaderValue::operator=(
HeaderValue&& other) {
storage_ = other.storage_;
fragments_ = std::move(other.fragments_);
@@ -64,13 +64,13 @@
return *this;
}
-void SpdyHeaderBlock::HeaderValue::set_storage(SpdyHeaderStorage* storage) {
+void Http2HeaderBlock::HeaderValue::set_storage(SpdyHeaderStorage* storage) {
storage_ = storage;
}
-SpdyHeaderBlock::HeaderValue::~HeaderValue() = default;
+Http2HeaderBlock::HeaderValue::~HeaderValue() = default;
-absl::string_view SpdyHeaderBlock::HeaderValue::ConsolidatedValue() const {
+absl::string_view Http2HeaderBlock::HeaderValue::ConsolidatedValue() const {
if (fragments_.empty()) {
return absl::string_view();
}
@@ -81,26 +81,26 @@
return fragments_[0];
}
-void SpdyHeaderBlock::HeaderValue::Append(absl::string_view fragment) {
+void Http2HeaderBlock::HeaderValue::Append(absl::string_view fragment) {
size_ += (fragment.size() + separator_size_);
fragments_.push_back(fragment);
}
const std::pair<absl::string_view, absl::string_view>&
-SpdyHeaderBlock::HeaderValue::as_pair() const {
+Http2HeaderBlock::HeaderValue::as_pair() const {
pair_.second = ConsolidatedValue();
return pair_;
}
-SpdyHeaderBlock::iterator::iterator(MapType::const_iterator it) : it_(it) {}
+Http2HeaderBlock::iterator::iterator(MapType::const_iterator it) : it_(it) {}
-SpdyHeaderBlock::iterator::iterator(const iterator& other) = default;
+Http2HeaderBlock::iterator::iterator(const iterator& other) = default;
-SpdyHeaderBlock::iterator::~iterator() = default;
+Http2HeaderBlock::iterator::~iterator() = default;
-SpdyHeaderBlock::ValueProxy::ValueProxy(
- SpdyHeaderBlock* block,
- SpdyHeaderBlock::MapType::iterator lookup_result,
+Http2HeaderBlock::ValueProxy::ValueProxy(
+ Http2HeaderBlock* block,
+ Http2HeaderBlock::MapType::iterator lookup_result,
const absl::string_view key,
size_t* spdy_header_block_value_size)
: block_(block),
@@ -109,7 +109,7 @@
spdy_header_block_value_size_(spdy_header_block_value_size),
valid_(true) {}
-SpdyHeaderBlock::ValueProxy::ValueProxy(ValueProxy&& other)
+Http2HeaderBlock::ValueProxy::ValueProxy(ValueProxy&& other)
: block_(other.block_),
lookup_result_(other.lookup_result_),
key_(other.key_),
@@ -118,8 +118,8 @@
other.valid_ = false;
}
-SpdyHeaderBlock::ValueProxy& SpdyHeaderBlock::ValueProxy::operator=(
- SpdyHeaderBlock::ValueProxy&& other) {
+Http2HeaderBlock::ValueProxy& Http2HeaderBlock::ValueProxy::operator=(
+ Http2HeaderBlock::ValueProxy&& other) {
block_ = other.block_;
lookup_result_ = other.lookup_result_;
key_ = other.key_;
@@ -129,17 +129,17 @@
return *this;
}
-SpdyHeaderBlock::ValueProxy::~ValueProxy() {
+Http2HeaderBlock::ValueProxy::~ValueProxy() {
// If the ValueProxy is destroyed while lookup_result_ == block_->end(),
// the assignment operator was never used, and the block's SpdyHeaderStorage
// can reclaim the memory used by the key. This makes lookup-only access to
- // SpdyHeaderBlock through operator[] memory-neutral.
+ // Http2HeaderBlock through operator[] memory-neutral.
if (valid_ && lookup_result_ == block_->map_.end()) {
block_->storage_.Rewind(key_);
}
}
-SpdyHeaderBlock::ValueProxy& SpdyHeaderBlock::ValueProxy::operator=(
+Http2HeaderBlock::ValueProxy& Http2HeaderBlock::ValueProxy::operator=(
absl::string_view value) {
*spdy_header_block_value_size_ += value.size();
SpdyHeaderStorage* storage = &block_->storage_;
@@ -158,7 +158,7 @@
return *this;
}
-bool SpdyHeaderBlock::ValueProxy::operator==(absl::string_view value) const {
+bool Http2HeaderBlock::ValueProxy::operator==(absl::string_view value) const {
if (lookup_result_ == block_->map_.end()) {
return false;
} else {
@@ -166,7 +166,7 @@
}
}
-std::string SpdyHeaderBlock::ValueProxy::as_string() const {
+std::string Http2HeaderBlock::ValueProxy::as_string() const {
if (lookup_result_ == block_->map_.end()) {
return "";
} else {
@@ -174,9 +174,9 @@
}
}
-SpdyHeaderBlock::SpdyHeaderBlock() : map_(kInitialMapBuckets) {}
+Http2HeaderBlock::Http2HeaderBlock() : map_(kInitialMapBuckets) {}
-SpdyHeaderBlock::SpdyHeaderBlock(SpdyHeaderBlock&& other)
+Http2HeaderBlock::Http2HeaderBlock(Http2HeaderBlock&& other)
: map_(kInitialMapBuckets) {
map_.swap(other.map_);
storage_ = std::move(other.storage_);
@@ -187,9 +187,9 @@
value_size_ = other.value_size_;
}
-SpdyHeaderBlock::~SpdyHeaderBlock() = default;
+Http2HeaderBlock::~Http2HeaderBlock() = default;
-SpdyHeaderBlock& SpdyHeaderBlock::operator=(SpdyHeaderBlock&& other) {
+Http2HeaderBlock& Http2HeaderBlock::operator=(Http2HeaderBlock&& other) {
map_.swap(other.map_);
storage_ = std::move(other.storage_);
for (auto& p : map_) {
@@ -200,23 +200,23 @@
return *this;
}
-SpdyHeaderBlock SpdyHeaderBlock::Clone() const {
- SpdyHeaderBlock copy;
+Http2HeaderBlock Http2HeaderBlock::Clone() const {
+ Http2HeaderBlock copy;
for (const auto& p : *this) {
copy.AppendHeader(p.first, p.second);
}
return copy;
}
-bool SpdyHeaderBlock::operator==(const SpdyHeaderBlock& other) const {
+bool Http2HeaderBlock::operator==(const Http2HeaderBlock& other) const {
return size() == other.size() && std::equal(begin(), end(), other.begin());
}
-bool SpdyHeaderBlock::operator!=(const SpdyHeaderBlock& other) const {
+bool Http2HeaderBlock::operator!=(const Http2HeaderBlock& other) const {
return !(operator==(other));
}
-std::string SpdyHeaderBlock::DebugString() const {
+std::string Http2HeaderBlock::DebugString() const {
if (empty()) {
return "{}";
}
@@ -229,7 +229,7 @@
return output;
}
-void SpdyHeaderBlock::erase(absl::string_view key) {
+void Http2HeaderBlock::erase(absl::string_view key) {
auto iter = map_.find(key);
if (iter != map_.end()) {
SPDY_DVLOG(1) << "Erasing header with name: " << key;
@@ -239,14 +239,14 @@
}
}
-void SpdyHeaderBlock::clear() {
+void Http2HeaderBlock::clear() {
key_size_ = 0;
value_size_ = 0;
map_.clear();
storage_.Clear();
}
-void SpdyHeaderBlock::insert(const SpdyHeaderBlock::value_type& value) {
+void Http2HeaderBlock::insert(const Http2HeaderBlock::value_type& value) {
// TODO(birenroy): Write new value in place of old value, if it fits.
value_size_ += value.second.size();
@@ -264,7 +264,7 @@
}
}
-SpdyHeaderBlock::ValueProxy SpdyHeaderBlock::operator[](
+Http2HeaderBlock::ValueProxy Http2HeaderBlock::operator[](
const absl::string_view key) {
SPDY_DVLOG(2) << "Operator[] saw key: " << key;
absl::string_view out_key;
@@ -282,8 +282,8 @@
return ValueProxy(this, iter, out_key, &value_size_);
}
-void SpdyHeaderBlock::AppendValueOrAddHeader(const absl::string_view key,
- const absl::string_view value) {
+void Http2HeaderBlock::AppendValueOrAddHeader(const absl::string_view key,
+ const absl::string_view value) {
value_size_ += value.size();
auto iter = map_.find(key);
@@ -299,25 +299,25 @@
iter->second.Append(storage_.Write(value));
}
-size_t SpdyHeaderBlock::EstimateMemoryUsage() const {
+size_t Http2HeaderBlock::EstimateMemoryUsage() const {
// TODO(xunjieli): https://crbug.com/669108. Also include |map_| when EMU()
// supports linked_hash_map.
return SpdyEstimateMemoryUsage(storage_);
}
-void SpdyHeaderBlock::AppendHeader(const absl::string_view key,
- const absl::string_view value) {
+void Http2HeaderBlock::AppendHeader(const absl::string_view key,
+ const absl::string_view value) {
auto backed_key = WriteKey(key);
map_.emplace(std::make_pair(
backed_key, HeaderValue(&storage_, backed_key, storage_.Write(value))));
}
-absl::string_view SpdyHeaderBlock::WriteKey(const absl::string_view key) {
+absl::string_view Http2HeaderBlock::WriteKey(const absl::string_view key) {
key_size_ += key.size();
return storage_.Write(key);
}
-size_t SpdyHeaderBlock::bytes_allocated() const {
+size_t Http2HeaderBlock::bytes_allocated() const {
return storage_.bytes_allocated();
}
diff --git a/spdy/core/spdy_header_block.h b/spdy/core/spdy_header_block.h
index 1faf34d..b069d20 100644
--- a/spdy/core/spdy_header_block.h
+++ b/spdy/core/spdy_header_block.h
@@ -41,12 +41,12 @@
// Under the hood, this data structure uses large, contiguous blocks of memory
// to store names and values. Lookups may be performed with absl::string_view
// keys, and values are returned as absl::string_views (via ValueProxy, below).
-// Value absl::string_views are valid as long as the SpdyHeaderBlock exists;
-// allocated memory is never freed until SpdyHeaderBlock's destruction.
+// Value absl::string_views are valid as long as the Http2HeaderBlock exists;
+// allocated memory is never freed until Http2HeaderBlock's destruction.
//
// This implementation does not make much of an effort to minimize wasted space.
-// It's expected that keys are rarely deleted from a SpdyHeaderBlock.
-class QUICHE_EXPORT_PRIVATE SpdyHeaderBlock {
+// It's expected that keys are rarely deleted from a Http2HeaderBlock.
+class QUICHE_EXPORT_PRIVATE Http2HeaderBlock {
private:
// Stores a list of value fragments that can be joined later with a
// key-dependent separator.
@@ -75,7 +75,7 @@
const std::pair<absl::string_view, absl::string_view>& as_pair() const;
// Size estimate including separators. Used when keys are erased from
- // SpdyHeaderBlock.
+ // Http2HeaderBlock.
size_t SizeEstimate() const { return size_; }
private:
@@ -158,17 +158,17 @@
};
typedef iterator const_iterator;
- SpdyHeaderBlock();
- SpdyHeaderBlock(const SpdyHeaderBlock& other) = delete;
- SpdyHeaderBlock(SpdyHeaderBlock&& other);
- ~SpdyHeaderBlock();
+ Http2HeaderBlock();
+ Http2HeaderBlock(const Http2HeaderBlock& other) = delete;
+ Http2HeaderBlock(Http2HeaderBlock&& other);
+ ~Http2HeaderBlock();
- SpdyHeaderBlock& operator=(const SpdyHeaderBlock& other) = delete;
- SpdyHeaderBlock& operator=(SpdyHeaderBlock&& other);
- SpdyHeaderBlock Clone() const;
+ Http2HeaderBlock& operator=(const Http2HeaderBlock& other) = delete;
+ Http2HeaderBlock& operator=(Http2HeaderBlock&& other);
+ Http2HeaderBlock Clone() const;
- bool operator==(const SpdyHeaderBlock& other) const;
- bool operator!=(const SpdyHeaderBlock& other) const;
+ bool operator==(const Http2HeaderBlock& other) const;
+ bool operator!=(const Http2HeaderBlock& other) const;
// Provides a human readable multi-line representation of the stored header
// keys and values.
@@ -202,8 +202,8 @@
void AppendValueOrAddHeader(const absl::string_view key,
const absl::string_view value);
- // This object provides automatic conversions that allow SpdyHeaderBlock to be
- // nearly a drop-in replacement for
+ // This object provides automatic conversions that allow Http2HeaderBlock to
+ // be nearly a drop-in replacement for
// SpdyLinkedHashMap<std::string, std::string>.
// It reads data from or writes data to a SpdyHeaderStorage.
class QUICHE_EXPORT_PRIVATE ValueProxy {
@@ -218,7 +218,7 @@
ValueProxy(const ValueProxy& other) = delete;
ValueProxy& operator=(const ValueProxy& other) = delete;
- // Assignment modifies the underlying SpdyHeaderBlock.
+ // Assignment modifies the underlying Http2HeaderBlock.
ValueProxy& operator=(absl::string_view value);
// Provides easy comparison against absl::string_view.
@@ -227,16 +227,16 @@
std::string as_string() const;
private:
- friend class SpdyHeaderBlock;
+ friend class Http2HeaderBlock;
friend class test::ValueProxyPeer;
- ValueProxy(SpdyHeaderBlock* block,
- SpdyHeaderBlock::MapType::iterator lookup_result,
+ ValueProxy(Http2HeaderBlock* block,
+ Http2HeaderBlock::MapType::iterator lookup_result,
const absl::string_view key,
size_t* spdy_header_block_value_size);
- SpdyHeaderBlock* block_;
- SpdyHeaderBlock::MapType::iterator lookup_result_;
+ Http2HeaderBlock* block_;
+ Http2HeaderBlock::MapType::iterator lookup_result_;
absl::string_view key_;
size_t* spdy_header_block_value_size_;
bool valid_;
@@ -290,6 +290,9 @@
size_t value_size_ = 0;
};
+// TODO(b/156770486): Remove this alias when the rename is complete.
+using SpdyHeaderBlock = Http2HeaderBlock;
+
} // namespace spdy
#endif // QUICHE_SPDY_CORE_SPDY_HEADER_BLOCK_H_
diff --git a/spdy/core/spdy_header_block_test.cc b/spdy/core/spdy_header_block_test.cc
index a8dbe01..9fd7b68 100644
--- a/spdy/core/spdy_header_block_test.cc
+++ b/spdy/core/spdy_header_block_test.cc
@@ -17,7 +17,7 @@
class ValueProxyPeer {
public:
- static absl::string_view key(SpdyHeaderBlock::ValueProxy* p) {
+ static absl::string_view key(Http2HeaderBlock::ValueProxy* p) {
return p->key_;
}
};
@@ -27,9 +27,9 @@
return std::make_pair(k, v);
}
-// This test verifies that SpdyHeaderBlock behaves correctly when empty.
-TEST(SpdyHeaderBlockTest, EmptyBlock) {
- SpdyHeaderBlock block;
+// This test verifies that Http2HeaderBlock behaves correctly when empty.
+TEST(Http2HeaderBlockTest, EmptyBlock) {
+ Http2HeaderBlock block;
EXPECT_TRUE(block.empty());
EXPECT_EQ(0u, block.size());
EXPECT_EQ(block.end(), block.find("foo"));
@@ -39,8 +39,8 @@
block.erase("bar");
}
-TEST(SpdyHeaderBlockTest, KeyMemoryReclaimedOnLookup) {
- SpdyHeaderBlock block;
+TEST(Http2HeaderBlockTest, KeyMemoryReclaimedOnLookup) {
+ Http2HeaderBlock block;
absl::string_view copied_key1;
{
auto proxy1 = block["some key name"];
@@ -62,7 +62,7 @@
block["some other key name"] = "some value";
}
// Nothing should blow up when proxy1 is destructed, and we should be able to
- // modify and access the SpdyHeaderBlock.
+ // modify and access the Http2HeaderBlock.
block["key"] = "value";
EXPECT_EQ("value", block["key"]);
EXPECT_EQ("some value", block["some other key name"]);
@@ -70,8 +70,8 @@
}
// This test verifies that headers can be set in a variety of ways.
-TEST(SpdyHeaderBlockTest, AddHeaders) {
- SpdyHeaderBlock block;
+TEST(Http2HeaderBlockTest, AddHeaders) {
+ Http2HeaderBlock block;
block["foo"] = std::string(300, 'x');
block["bar"] = "baz";
block["qux"] = "qux1";
@@ -89,29 +89,29 @@
EXPECT_EQ(block.end(), block.find("key"));
}
-// This test verifies that SpdyHeaderBlock can be copied using Clone().
-TEST(SpdyHeaderBlockTest, CopyBlocks) {
- SpdyHeaderBlock block1;
+// This test verifies that Http2HeaderBlock can be copied using Clone().
+TEST(Http2HeaderBlockTest, CopyBlocks) {
+ Http2HeaderBlock block1;
block1["foo"] = std::string(300, 'x');
block1["bar"] = "baz";
block1.insert(std::make_pair("qux", "qux1"));
- SpdyHeaderBlock block2 = block1.Clone();
- SpdyHeaderBlock block3(block1.Clone());
+ Http2HeaderBlock block2 = block1.Clone();
+ Http2HeaderBlock block3(block1.Clone());
EXPECT_EQ(block1, block2);
EXPECT_EQ(block1, block3);
}
-TEST(SpdyHeaderBlockTest, Equality) {
+TEST(Http2HeaderBlockTest, Equality) {
// Test equality and inequality operators.
- SpdyHeaderBlock block1;
+ Http2HeaderBlock block1;
block1["foo"] = "bar";
- SpdyHeaderBlock block2;
+ Http2HeaderBlock block2;
block2["foo"] = "bar";
- SpdyHeaderBlock block3;
+ Http2HeaderBlock block3;
block3["baz"] = "qux";
EXPECT_EQ(block1, block2);
@@ -121,28 +121,28 @@
EXPECT_NE(block1, block2);
}
-SpdyHeaderBlock ReturnTestHeaderBlock() {
- SpdyHeaderBlock block;
+Http2HeaderBlock ReturnTestHeaderBlock() {
+ Http2HeaderBlock block;
block["foo"] = "bar";
block.insert(std::make_pair("foo2", "baz"));
return block;
}
// Test that certain methods do not crash on moved-from instances.
-TEST(SpdyHeaderBlockTest, MovedFromIsValid) {
- SpdyHeaderBlock block1;
+TEST(Http2HeaderBlockTest, MovedFromIsValid) {
+ Http2HeaderBlock block1;
block1["foo"] = "bar";
- SpdyHeaderBlock block2(std::move(block1));
+ Http2HeaderBlock block2(std::move(block1));
EXPECT_THAT(block2, ElementsAre(Pair("foo", "bar")));
block1["baz"] = "qux"; // NOLINT testing post-move behavior
- SpdyHeaderBlock block3(std::move(block1));
+ Http2HeaderBlock block3(std::move(block1));
block1["foo"] = "bar"; // NOLINT testing post-move behavior
- SpdyHeaderBlock block4(std::move(block1));
+ Http2HeaderBlock block4(std::move(block1));
block1.clear(); // NOLINT testing post-move behavior
EXPECT_TRUE(block1.empty());
@@ -150,7 +150,7 @@
block1["foo"] = "bar";
EXPECT_THAT(block1, ElementsAre(Pair("foo", "bar")));
- SpdyHeaderBlock block5 = ReturnTestHeaderBlock();
+ Http2HeaderBlock block5 = ReturnTestHeaderBlock();
block5.AppendValueOrAddHeader("foo", "bar2");
EXPECT_THAT(block5, ElementsAre(Pair("foo", std::string("bar\0bar2", 8)),
Pair("foo2", "baz")));
@@ -158,8 +158,8 @@
// This test verifies that headers can be appended to no matter how they were
// added originally.
-TEST(SpdyHeaderBlockTest, AppendHeaders) {
- SpdyHeaderBlock block;
+TEST(Http2HeaderBlockTest, AppendHeaders) {
+ Http2HeaderBlock block;
block["foo"] = "foo";
block.AppendValueOrAddHeader("foo", "bar");
EXPECT_EQ(Pair("foo", std::string("foo\0bar", 7)), *block.find("foo"));
@@ -192,8 +192,8 @@
EXPECT_EQ("singleton", block["h4"]);
}
-TEST(SpdyHeaderBlockTest, CompareValueToStringPiece) {
- SpdyHeaderBlock block;
+TEST(Http2HeaderBlockTest, CompareValueToStringPiece) {
+ Http2HeaderBlock block;
block["foo"] = "foo";
block.AppendValueOrAddHeader("foo", "bar");
const auto& val = block["foo"];
@@ -213,10 +213,10 @@
EXPECT_FALSE(val2 == absl::string_view(""));
}
-// This test demonstrates that the SpdyHeaderBlock data structure does not place
-// any limitations on the characters present in the header names.
-TEST(SpdyHeaderBlockTest, UpperCaseNames) {
- SpdyHeaderBlock block;
+// This test demonstrates that the Http2HeaderBlock data structure does not
+// place any limitations on the characters present in the header names.
+TEST(Http2HeaderBlockTest, UpperCaseNames) {
+ Http2HeaderBlock block;
block["Foo"] = "foo";
block.AppendValueOrAddHeader("Foo", "bar");
EXPECT_NE(block.end(), block.find("foo"));
@@ -230,7 +230,7 @@
}
namespace {
-size_t SpdyHeaderBlockSize(const SpdyHeaderBlock& block) {
+size_t Http2HeaderBlockSize(const Http2HeaderBlock& block) {
size_t size = 0;
for (const auto& pair : block) {
size += pair.first.size() + pair.second.size();
@@ -239,38 +239,38 @@
}
} // namespace
-// Tests SpdyHeaderBlock SizeEstimate().
-TEST(SpdyHeaderBlockTest, TotalBytesUsed) {
- SpdyHeaderBlock block;
+// Tests Http2HeaderBlock SizeEstimate().
+TEST(Http2HeaderBlockTest, TotalBytesUsed) {
+ Http2HeaderBlock block;
const size_t value_size = 300;
block["foo"] = std::string(value_size, 'x');
- EXPECT_EQ(block.TotalBytesUsed(), SpdyHeaderBlockSize(block));
+ EXPECT_EQ(block.TotalBytesUsed(), Http2HeaderBlockSize(block));
block.insert(std::make_pair("key", std::string(value_size, 'x')));
- EXPECT_EQ(block.TotalBytesUsed(), SpdyHeaderBlockSize(block));
+ EXPECT_EQ(block.TotalBytesUsed(), Http2HeaderBlockSize(block));
block.AppendValueOrAddHeader("abc", std::string(value_size, 'x'));
- EXPECT_EQ(block.TotalBytesUsed(), SpdyHeaderBlockSize(block));
+ EXPECT_EQ(block.TotalBytesUsed(), Http2HeaderBlockSize(block));
// Replace value for existing key.
block["foo"] = std::string(value_size, 'x');
- EXPECT_EQ(block.TotalBytesUsed(), SpdyHeaderBlockSize(block));
+ EXPECT_EQ(block.TotalBytesUsed(), Http2HeaderBlockSize(block));
block.insert(std::make_pair("key", std::string(value_size, 'x')));
- EXPECT_EQ(block.TotalBytesUsed(), SpdyHeaderBlockSize(block));
+ EXPECT_EQ(block.TotalBytesUsed(), Http2HeaderBlockSize(block));
// Add value for existing key.
block.AppendValueOrAddHeader("abc", std::string(value_size, 'x'));
- EXPECT_EQ(block.TotalBytesUsed(), SpdyHeaderBlockSize(block));
+ EXPECT_EQ(block.TotalBytesUsed(), Http2HeaderBlockSize(block));
- // Copies/clones SpdyHeaderBlock.
+ // Copies/clones Http2HeaderBlock.
size_t block_size = block.TotalBytesUsed();
- SpdyHeaderBlock block_copy = std::move(block);
+ Http2HeaderBlock block_copy = std::move(block);
EXPECT_EQ(block_size, block_copy.TotalBytesUsed());
// Erases key.
block_copy.erase("foo");
- EXPECT_EQ(block_copy.TotalBytesUsed(), SpdyHeaderBlockSize(block_copy));
+ EXPECT_EQ(block_copy.TotalBytesUsed(), Http2HeaderBlockSize(block_copy));
block_copy.erase("key");
- EXPECT_EQ(block_copy.TotalBytesUsed(), SpdyHeaderBlockSize(block_copy));
+ EXPECT_EQ(block_copy.TotalBytesUsed(), Http2HeaderBlockSize(block_copy));
block_copy.erase("abc");
- EXPECT_EQ(block_copy.TotalBytesUsed(), SpdyHeaderBlockSize(block_copy));
+ EXPECT_EQ(block_copy.TotalBytesUsed(), Http2HeaderBlockSize(block_copy));
}
} // namespace test