| 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/tools/quic/spdy_utils.h" | 5 #include "net/tools/quic/spdy_utils.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 string SpdyUtils::SerializeResponseHeaders( | 151 string SpdyUtils::SerializeResponseHeaders( |
| 152 const BalsaHeaders& response_headers) { | 152 const BalsaHeaders& response_headers) { |
| 153 SpdyHeaderBlock block = ResponseHeadersToSpdyHeaders(response_headers); | 153 SpdyHeaderBlock block = ResponseHeadersToSpdyHeaders(response_headers); |
| 154 | 154 |
| 155 return SerializeUncompressedHeaders(block); | 155 return SerializeUncompressedHeaders(block); |
| 156 } | 156 } |
| 157 | 157 |
| 158 // static | 158 // static |
| 159 string SpdyUtils::SerializeUncompressedHeaders(const SpdyHeaderBlock& headers) { | 159 string SpdyUtils::SerializeUncompressedHeaders(const SpdyHeaderBlock& headers) { |
| 160 int length = SpdyFramer::GetSerializedLength(SPDY3, &headers); | 160 int length = SpdyFramer::GetSerializedLength(SPDY3, &headers); |
| 161 SpdyFrameBuilder builder(length); | 161 SpdyFrameBuilder builder(length, SPDY3); |
| 162 SpdyFramer::WriteHeaderBlock(&builder, SPDY3, &headers); | 162 SpdyFramer::WriteHeaderBlock(&builder, SPDY3, &headers); |
| 163 scoped_ptr<SpdyFrame> block(builder.take()); | 163 scoped_ptr<SpdyFrame> block(builder.take()); |
| 164 return string(block->data(), length); | 164 return string(block->data(), length); |
| 165 } | 165 } |
| 166 | 166 |
| 167 bool IsSpecialSpdyHeader(SpdyHeaderBlock::const_iterator header, | 167 bool IsSpecialSpdyHeader(SpdyHeaderBlock::const_iterator header, |
| 168 BalsaHeaders* headers) { | 168 BalsaHeaders* headers) { |
| 169 if (header->first.empty() || header->second.empty()) { | 169 if (header->first.empty() || header->second.empty()) { |
| 170 return true; | 170 return true; |
| 171 } | 171 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 for (BlockIt it = header_block.begin(); it != header_block.end(); ++it) { | 257 for (BlockIt it = header_block.begin(); it != header_block.end(); ++it) { |
| 258 if (!IsSpecialSpdyHeader(it, request_headers)) { | 258 if (!IsSpecialSpdyHeader(it, request_headers)) { |
| 259 request_headers->AppendHeader(it->first, it->second); | 259 request_headers->AppendHeader(it->first, it->second); |
| 260 } | 260 } |
| 261 } | 261 } |
| 262 return true; | 262 return true; |
| 263 } | 263 } |
| 264 | 264 |
| 265 } // namespace tools | 265 } // namespace tools |
| 266 } // namespace net | 266 } // namespace net |
| OLD | NEW |