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

Unified Diff: net/http2/http2_structures.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/http2_structures.h ('k') | net/http2/http2_structures_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http2/http2_structures.cc
diff --git a/net/http2/http2_structures.cc b/net/http2/http2_structures.cc
new file mode 100644
index 0000000000000000000000000000000000000000..833604308029fb6e4a248ce54be1b13f04a219fd
--- /dev/null
+++ b/net/http2/http2_structures.cc
@@ -0,0 +1,138 @@
+// 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/http2_structures.h"
+
+#include <cstring> // For std::memcmp
+#include <sstream>
+#include <string>
+
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
+
+using std::string;
+using base::StringPiece;
+
+namespace net {
+
+// Http2FrameHeader:
+
+bool Http2FrameHeader::IsProbableHttpResponse() const {
+ return (payload_length == 0x485454 && // "HTT"
+ static_cast<char>(type) == 'P' && // "P"
+ flags == '/'); // "/"
+}
+
+string Http2FrameHeader::ToString() const {
+ std::stringstream ss;
+ ss << "length=" << payload_length << ", type=" << Http2FrameTypeToString(type)
+ << ", flags=" << FlagsToString() << ", stream=" << stream_id;
+ return ss.str();
+}
+
+string Http2FrameHeader::FlagsToString() const {
+ return Http2FrameFlagsToString(type, flags);
+}
+
+bool operator==(const Http2FrameHeader& a, const Http2FrameHeader& b) {
+ return a.payload_length == b.payload_length && a.stream_id == b.stream_id &&
+ a.type == b.type && a.flags == b.flags;
+}
+
+std::ostream& operator<<(std::ostream& out, const Http2FrameHeader& v) {
+ return out << v.ToString();
+}
+
+// Http2PriorityFields:
+
+bool operator==(const Http2PriorityFields& a, const Http2PriorityFields& b) {
+ return a.stream_dependency == b.stream_dependency && a.weight == b.weight;
+}
+
+std::string Http2PriorityFields::ToString() const {
+ std::stringstream ss;
+ ss << "E=" << (is_exclusive ? "true" : "false")
+ << ", stream=" << stream_dependency
+ << ", weight=" << static_cast<uint32_t>(weight);
+ return ss.str();
+}
+
+std::ostream& operator<<(std::ostream& out, const Http2PriorityFields& v) {
+ return out << v.ToString();
+}
+
+// Http2RstStreamFields:
+
+bool operator==(const Http2RstStreamFields& a, const Http2RstStreamFields& b) {
+ return a.error_code == b.error_code;
+}
+
+std::ostream& operator<<(std::ostream& out, const Http2RstStreamFields& v) {
+ return out << "error_code=" << v.error_code;
+}
+
+// Http2SettingFields:
+
+bool operator==(const Http2SettingFields& a, const Http2SettingFields& b) {
+ return a.parameter == b.parameter && a.value == b.value;
+}
+std::ostream& operator<<(std::ostream& out, const Http2SettingFields& v) {
+ return out << "parameter=" << v.parameter << ", value=" << v.value;
+}
+
+// Http2PushPromiseFields:
+
+bool operator==(const Http2PushPromiseFields& a,
+ const Http2PushPromiseFields& b) {
+ return a.promised_stream_id == b.promised_stream_id;
+}
+
+std::ostream& operator<<(std::ostream& out, const Http2PushPromiseFields& v) {
+ return out << "promised_stream_id=" << v.promised_stream_id;
+}
+
+// Http2PingFields:
+
+bool operator==(const Http2PingFields& a, const Http2PingFields& b) {
+ static_assert((sizeof a.opaque_data) == Http2PingFields::EncodedSize(),
+ "Why not the same size?");
+ return 0 == std::memcmp(a.opaque_data, b.opaque_data, sizeof a.opaque_data);
+}
+
+std::ostream& operator<<(std::ostream& out, const Http2PingFields& v) {
+ string s = base::HexEncode(v.opaque_data, sizeof v.opaque_data);
+ base::CollapseWhitespaceASCII(s, /*trim_sequences_with_line_breaks=*/false);
+ return out << "opaque_data=[" << s << "]";
+}
+
+// Http2GoAwayFields:
+
+bool operator==(const Http2GoAwayFields& a, const Http2GoAwayFields& b) {
+ return a.last_stream_id == b.last_stream_id && a.error_code == b.error_code;
+}
+std::ostream& operator<<(std::ostream& out, const Http2GoAwayFields& v) {
+ return out << "last_stream_id=" << v.last_stream_id
+ << ", error_code=" << v.error_code;
+}
+
+// Http2WindowUpdateFields:
+
+bool operator==(const Http2WindowUpdateFields& a,
+ const Http2WindowUpdateFields& b) {
+ return a.window_size_increment == b.window_size_increment;
+}
+std::ostream& operator<<(std::ostream& out, const Http2WindowUpdateFields& v) {
+ return out << "window_size_increment=" << v.window_size_increment;
+}
+
+// Http2AltSvcFields:
+
+bool operator==(const Http2AltSvcFields& a, const Http2AltSvcFields& b) {
+ return a.origin_length == b.origin_length;
+}
+std::ostream& operator<<(std::ostream& out, const Http2AltSvcFields& v) {
+ return out << "origin_length=" << v.origin_length;
+}
+
+} // namespace net
« no previous file with comments | « net/http2/http2_structures.h ('k') | net/http2/http2_structures_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698