Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Unified Diff: net/http2/hpack/tools/hpack_example.cc

Issue 2293613002: Add new HTTP/2 and HPACK decoder in net/http2/. (Closed)
Patch Set: Replace LOG(INFO) by VLOG(2) in DecodeBufferTest.SlowDecodeTestStruct so that trybots do not fail. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http2/hpack/tools/hpack_example.h ('k') | net/http2/http2_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http2/hpack/tools/hpack_example.cc
diff --git a/net/http2/hpack/tools/hpack_example.cc b/net/http2/hpack/tools/hpack_example.cc
new file mode 100644
index 0000000000000000000000000000000000000000..72fd5810e991d0ef563e9c64cf2d3c9265a97489
--- /dev/null
+++ b/net/http2/hpack/tools/hpack_example.cc
@@ -0,0 +1,61 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/http2/hpack/tools/hpack_example.h"
+
+#include <ctype.h>
+
+#include "base/logging.h"
+#include "net/spdy/spdy_test_utils.h"
+
+using base::StringPiece;
+using std::string;
+
+namespace net {
+namespace test {
+namespace {
+
+void HpackExampleToStringOrDie(StringPiece example, string* output) {
+ while (!example.empty()) {
+ const char c0 = example[0];
+ if (isxdigit(c0)) {
+ CHECK_GT(example.size(), 1u) << "Truncated hex byte?";
+ const char c1 = example[1];
+ CHECK(isxdigit(c1)) << "Found half a byte?";
+ *output += a2b_hex(example.substr(0, 2).as_string().c_str());
+ example.remove_prefix(2);
+ continue;
+ }
+ if (isspace(c0)) {
+ example.remove_prefix(1);
+ continue;
+ }
+ if (example.starts_with("|")) {
+ // Start of a comment. Skip to end of line or of input.
+ auto pos = example.find('\n');
+ if (pos == StringPiece::npos) {
+ // End of input.
+ break;
+ }
+ example.remove_prefix(pos + 1);
+ continue;
+ }
+ CHECK(false) << "Can't parse byte " << static_cast<int>(c0) << " (0x"
+ << std::hex << c0 << ")"
+ << "\nExample: " << example;
+ }
+ CHECK_LT(0u, output->size()) << "Example is empty.";
+ return;
+}
+
+} // namespace
+
+string HpackExampleToStringOrDie(StringPiece example) {
+ string output;
+ HpackExampleToStringOrDie(example, &output);
+ return output;
+}
+
+} // namespace test
+} // namespace net
« no previous file with comments | « net/http2/hpack/tools/hpack_example.h ('k') | net/http2/http2_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698