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

Side by Side Diff: net/quic/spdy_utils.cc

Issue 1357953002: Replace the existing SpdyHeaderBlock typedef with a class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add NET_EXPORT to fix compile error on win_chromium_compile_dbg_ng. Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « net/net.gypi ('k') | net/quic/test_tools/quic_test_packet_maker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/quic/spdy_utils.h" 5 #include "net/quic/spdy_utils.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "net/spdy/spdy_frame_builder.h" 8 #include "net/spdy/spdy_frame_builder.h"
9 #include "net/spdy/spdy_framer.h" 9 #include "net/spdy/spdy_framer.h"
10 #include "net/spdy/spdy_protocol.h" 10 #include "net/spdy/spdy_protocol.h"
11 11
12 using std::string; 12 using std::string;
13 13
14 namespace net { 14 namespace net {
15 15
16 // static 16 // static
17 SpdyMajorVersion SpdyUtils::GetSpdyVersionForQuicVersion( 17 SpdyMajorVersion SpdyUtils::GetSpdyVersionForQuicVersion(
18 QuicVersion quic_version) { 18 QuicVersion quic_version) {
19 if (quic_version > QUIC_VERSION_24) { 19 if (quic_version > QUIC_VERSION_24) {
20 return HTTP2; 20 return HTTP2;
21 } 21 }
22 return SPDY3; 22 return SPDY3;
23 } 23 }
24 24
25 // static 25 // static
26 SpdyHeaderBlock SpdyUtils::ConvertSpdy3ResponseHeadersToSpdy4( 26 SpdyHeaderBlock SpdyUtils::ConvertSpdy3ResponseHeadersToSpdy4(
27 SpdyHeaderBlock response_headers) { 27 SpdyHeaderBlock response_headers) {
28 // SPDY/4 headers include neither the version field nor the response details. 28 // SPDY/4 headers include neither the version field nor the response details.
29 response_headers.erase(":version"); 29 response_headers.erase(":version");
30 size_t end_of_code = response_headers[":status"].find(' '); 30 StringPiece status_value = response_headers[":status"];
31 size_t end_of_code = status_value.find(' ');
31 if (end_of_code != string::npos) { 32 if (end_of_code != string::npos) {
32 response_headers[":status"].erase(end_of_code); 33 response_headers[":status"] = status_value.substr(0, end_of_code);
33 } 34 }
34 return response_headers; 35 return response_headers;
35 } 36 }
36 37
37 // static 38 // static
38 string SpdyUtils::SerializeUncompressedHeaders(const SpdyHeaderBlock& headers, 39 string SpdyUtils::SerializeUncompressedHeaders(const SpdyHeaderBlock& headers,
39 QuicVersion quic_version) { 40 QuicVersion quic_version) {
40 SpdyMajorVersion spdy_version = GetSpdyVersionForQuicVersion(quic_version); 41 SpdyMajorVersion spdy_version = GetSpdyVersionForQuicVersion(quic_version);
41 42
42 size_t length = SpdyFramer::GetSerializedLength(spdy_version, &headers); 43 size_t length = SpdyFramer::GetSerializedLength(spdy_version, &headers);
43 SpdyFrameBuilder builder(length, spdy_version); 44 SpdyFrameBuilder builder(length, spdy_version);
44 SpdyFramer::WriteHeaderBlock(&builder, spdy_version, &headers); 45 SpdyFramer::WriteHeaderBlock(&builder, spdy_version, &headers);
45 scoped_ptr<SpdyFrame> block(builder.take()); 46 scoped_ptr<SpdyFrame> block(builder.take());
46 return string(block->data(), length); 47 return string(block->data(), length);
47 } 48 }
48 49
49 } // namespace net 50 } // namespace net
OLDNEW
« no previous file with comments | « net/net.gypi ('k') | net/quic/test_tools/quic_test_packet_maker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698