summaryrefslogtreecommitdiffstats
path: root/net/flip
diff options
context:
space:
mode:
authormbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-14 18:40:21 +0000
committermbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-14 18:40:21 +0000
commit7f11485cd03b04404ebd65603e3b3a09a37737d4 (patch)
tree5a7e24c8e3f1c373e7dfb3a62e971efa34dd434c /net/flip
parent1f98739a6ce90232c5236fae59879e8c93662935 (diff)
downloadchromium_src-7f11485cd03b04404ebd65603e3b3a09a37737d4.zip
chromium_src-7f11485cd03b04404ebd65603e3b3a09a37737d4.tar.gz
chromium_src-7f11485cd03b04404ebd65603e3b3a09a37737d4.tar.bz2
Fix multi-valued headers to and from the server.
This is basically for Set-Cookie, but the solution is generic. If the HTTP layer had issued multiple, duplicate named headers, we send a single name-value pair where the value is a null-character separated list of the original headers. So: Set-Cookie: foo Set-Cookie: bar Becomes Set-cookie "foo\0bar" BUG=none TEST=none Review URL: http://codereview.chromium.org/391061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32007 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/flip')
-rw-r--r--net/flip/flip_session.cc9
-rwxr-xr-xnet/flip/flip_stream.cc27
2 files changed, 31 insertions, 5 deletions
diff --git a/net/flip/flip_session.cc b/net/flip/flip_session.cc
index 9a1a1c7..c89db24 100644
--- a/net/flip/flip_session.cc
+++ b/net/flip/flip_session.cc
@@ -100,7 +100,14 @@ void CreateFlipHeadersFromHttpRequest(
"\r\n");
while (it.GetNext()) {
std::string name = StringToLowerASCII(it.name());
- (*headers)[name] = it.values();
+ if (headers->find(name) == headers->end()) {
+ (*headers)[name] = it.values();
+ } else {
+ std::string new_value = (*headers)[name];
+ new_value += "\0";
+ new_value += it.values();
+ (*headers)[name] = new_value;
+ }
}
(*headers)["method"] = info->method;
diff --git a/net/flip/flip_stream.cc b/net/flip/flip_stream.cc
index 2b8ced3..5c05a22 100755
--- a/net/flip/flip_stream.cc
+++ b/net/flip/flip_stream.cc
@@ -58,10 +58,29 @@ void FlipStream::OnReply(const flip::FlipHeaderBlock* headers) {
raw_headers.append("\0", 1);
flip::FlipHeaderBlock::const_iterator it;
for (it = headers->begin(); it != headers->end(); ++it) {
- raw_headers.append(it->first);
- raw_headers.append(":", 1);
- raw_headers.append(it->second);
- raw_headers.append("\0", 1);
+ // For each value, if the server sends a NUL-separated
+ // list of values, we separate that back out into
+ // individual headers for each value in the list.
+ // e.g.
+ // Set-Cookie "foo\0bar"
+ // becomes
+ // Set-Cookie: foo\0
+ // Set-Cookie: bar\0
+ std::string value = it->second;
+ size_t start = 0;
+ size_t end = 0;
+ do {
+ end = value.find('\0', start);
+ std::string tval;
+ if (end != value.npos)
+ tval = value.substr(start, (end - start));
+ else
+ tval = value.substr(start);
+ raw_headers.append(it->first);
+ raw_headers.append(":", 1);
+ raw_headers.append(tval);
+ start = end + 1;
+ } while (end != value.npos);
}
LOG(INFO) << "FlipStream: SynReply received for " << stream_id_;