OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/spdy/spdy_framer.h" | 5 #include "net/spdy/spdy_framer.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 // manner that resists the length of the compressed data from compromising | 1323 // manner that resists the length of the compressed data from compromising |
1324 // cookie data. | 1324 // cookie data. |
1325 void SpdyFramer::WriteHeaderBlockToZ(const SpdyHeaderBlock* headers, | 1325 void SpdyFramer::WriteHeaderBlockToZ(const SpdyHeaderBlock* headers, |
1326 z_stream* z) const { | 1326 z_stream* z) const { |
1327 unsigned length_length = 4; | 1327 unsigned length_length = 4; |
1328 if (protocol_version() < 3) | 1328 if (protocol_version() < 3) |
1329 length_length = 2; | 1329 length_length = 2; |
1330 | 1330 |
1331 WriteLengthZ(headers->size(), length_length, kZStandardData, z); | 1331 WriteLengthZ(headers->size(), length_length, kZStandardData, z); |
1332 | 1332 |
1333 std::map<std::string, std::string>::const_iterator it; | 1333 SpdyHeaderBlock::const_iterator it; |
1334 for (it = headers->begin(); it != headers->end(); ++it) { | 1334 for (it = headers->begin(); it != headers->end(); ++it) { |
1335 WriteLengthZ(it->first.size(), length_length, kZStandardData, z); | 1335 WriteLengthZ(it->first.size(), length_length, kZStandardData, z); |
1336 WriteZ(it->first, kZStandardData, z); | 1336 WriteZ(it->first, kZStandardData, z); |
1337 | 1337 |
1338 if (it->first == "cookie") { | 1338 if (it->first == "cookie") { |
1339 // We require the cookie values (save for the last) to end with a | 1339 // We require the cookie values (save for the last) to end with a |
1340 // semicolon and (save for the first) to start with a space. This is | 1340 // semicolon and (save for the first) to start with a space. This is |
1341 // typically the format that we are given them in but we reserialize them | 1341 // typically the format that we are given them in but we reserialize them |
1342 // to be sure. | 1342 // to be sure. |
1343 | 1343 |
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3243 #else | 3243 #else |
3244 WriteHeaderBlockToZ(&frame.header_block(), compressor); | 3244 WriteHeaderBlockToZ(&frame.header_block(), compressor); |
3245 #endif // defined(USE_SYSTEM_ZLIB) | 3245 #endif // defined(USE_SYSTEM_ZLIB) |
3246 | 3246 |
3247 int compressed_size = compressed_max_size - compressor->avail_out; | 3247 int compressed_size = compressed_max_size - compressor->avail_out; |
3248 builder->Seek(compressed_size); | 3248 builder->Seek(compressed_size); |
3249 builder->RewriteLength(*this); | 3249 builder->RewriteLength(*this); |
3250 } | 3250 } |
3251 | 3251 |
3252 } // namespace net | 3252 } // namespace net |
OLD | NEW |