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

Unified Diff: net/tools/quic/spdy_balsa_utils.cc

Issue 1976473003: Fixes header translation between SpdyHeaderBlock and other data structures. Not protected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@121370394
Patch Set: Created 4 years, 7 months 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/quic/spdy_utils_test.cc ('k') | net/tools/quic/spdy_balsa_utils_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/spdy_balsa_utils.cc
diff --git a/net/tools/quic/spdy_balsa_utils.cc b/net/tools/quic/spdy_balsa_utils.cc
index de87bbe0814f1e7f3d8f404e1d42c8bbbd39b4bd..8f1ebd2eac4bf05ad4bcf8ae8ff6104609be92bf 100644
--- a/net/tools/quic/spdy_balsa_utils.cc
+++ b/net/tools/quic/spdy_balsa_utils.cc
@@ -9,6 +9,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
+#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "net/base/linked_hash_map.h"
#include "net/quic/quic_flags.h"
@@ -118,7 +119,7 @@ void PopulateSpdyResponseHeaderBlock(SpdyMajorVersion version,
bool IsSpecialSpdyHeader(SpdyHeaderBlock::const_iterator header,
BalsaHeaders* headers) {
- return header->first.empty() || header->second.empty() ||
+ return header->first.empty() || /* header->second.empty() || */
header->first[0] == ':';
}
@@ -153,7 +154,18 @@ void SpdyHeadersToResponseHeaders(const SpdyHeaderBlock& header_block,
for (BlockIt it = header_block.begin(); it != header_block.end(); ++it) {
if (!IsSpecialSpdyHeader(it, request_headers)) {
- request_headers->AppendHeader(it->first, it->second);
+ if (it->second.empty()) {
+ request_headers->AppendHeader(it->first, it->second);
+ } else {
+ DVLOG(2) << "Splitting value: [" << it->second << "]"
+ << " for key: " << it->first;
+ for (string value :
+ base::SplitString(it->second, base::StringPiece("\0", 1),
+ base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
+ DVLOG(2) << "AppendHeader(" << it->first << ", " << value << ")";
+ request_headers->AppendHeader(it->first, StringPiece(value));
+ }
+ }
}
}
}
@@ -198,7 +210,18 @@ void SpdyHeadersToRequestHeaders(const SpdyHeaderBlock& header_block,
for (BlockIt it = header_block.begin(); it != header_block.end(); ++it) {
if (!IsSpecialSpdyHeader(it, request_headers)) {
- request_headers->AppendHeader(it->first, it->second);
+ if (it->second.empty()) {
+ request_headers->AppendHeader(it->first, it->second);
+ } else {
+ DVLOG(2) << "Splitting value: [" << it->second << "]"
+ << " for key: " << it->first;
+ for (string value :
+ base::SplitString(it->second, base::StringPiece("\0", 1),
+ base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
+ DVLOG(2) << "AppendHeader(" << it->first << ", " << value << ")";
+ request_headers->AppendHeader(it->first, StringPiece(value));
+ }
+ }
}
}
}
« no previous file with comments | « net/quic/spdy_utils_test.cc ('k') | net/tools/quic/spdy_balsa_utils_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698