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

Side by Side Diff: net/spdy/hpack_encoder.cc

Issue 533073004: HPACK: Split header fields in encoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/spdy/hpack_encoder.h ('k') | net/spdy/hpack_encoder_test.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/hpack_encoder.h" 5 #include "net/spdy/hpack_encoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "net/spdy/hpack_header_table.h" 10 #include "net/spdy/hpack_header_table.h"
(...skipping 19 matching lines...) Expand all
30 // Separate header set into pseudo-headers and regular headers. 30 // Separate header set into pseudo-headers and regular headers.
31 Representations pseudo_headers; 31 Representations pseudo_headers;
32 Representations regular_headers; 32 Representations regular_headers;
33 for (std::map<string, string>::const_iterator it = header_set.begin(); 33 for (std::map<string, string>::const_iterator it = header_set.begin();
34 it != header_set.end(); ++it) { 34 it != header_set.end(); ++it) {
35 if (it->first == "cookie") { 35 if (it->first == "cookie") {
36 // Note that there can only be one "cookie" header, because header_set is 36 // Note that there can only be one "cookie" header, because header_set is
37 // a map. 37 // a map.
38 CookieToCrumbs(*it, &regular_headers); 38 CookieToCrumbs(*it, &regular_headers);
39 } else if (it->first[0] == kPseudoHeaderPrefix) { 39 } else if (it->first[0] == kPseudoHeaderPrefix) {
40 pseudo_headers.push_back(make_pair( 40 DecomposeRepresentation(*it, &pseudo_headers);
41 StringPiece(it->first), StringPiece(it->second)));
42 } else { 41 } else {
43 regular_headers.push_back(make_pair( 42 DecomposeRepresentation(*it, &regular_headers);
44 StringPiece(it->first), StringPiece(it->second)));
45 } 43 }
46 } 44 }
47 45
48 // Encode pseudo-headers. 46 // Encode pseudo-headers.
49 for (Representations::const_iterator it = pseudo_headers.begin(); 47 for (Representations::const_iterator it = pseudo_headers.begin();
50 it != pseudo_headers.end(); ++it) { 48 it != pseudo_headers.end(); ++it) {
51 HpackEntry* entry = header_table_.GetByNameAndValue(it->first, it->second); 49 HpackEntry* entry = header_table_.GetByNameAndValue(it->first, it->second);
52 if (entry != NULL) { 50 if (entry != NULL) {
53 EmitIndex(entry); 51 EmitIndex(entry);
54 } else { 52 } else {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 if (pos != cookie.second.size() && cookie.second[pos] == ' ') { 191 if (pos != cookie.second.size() && cookie.second[pos] == ' ') {
194 pos++; 192 pos++;
195 } 193 }
196 } 194 }
197 // Sort crumbs and remove duplicates. 195 // Sort crumbs and remove duplicates.
198 std::sort(out->begin() + prior_size, out->end()); 196 std::sort(out->begin() + prior_size, out->end());
199 out->erase(std::unique(out->begin() + prior_size, out->end()), 197 out->erase(std::unique(out->begin() + prior_size, out->end()),
200 out->end()); 198 out->end());
201 } 199 }
202 200
201 // static
202 void HpackEncoder::DecomposeRepresentation(const Representation& header_field,
203 Representations* out) {
204 size_t pos = 0;
205 size_t end = 0;
206 while (end != StringPiece::npos) {
207 end = header_field.second.find('\0', pos);
208 out->push_back(make_pair(header_field.first,
209 header_field.second.substr(pos, end - pos)));
210 pos = end + 1;
211 }
212 }
213
203 } // namespace net 214 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/hpack_encoder.h ('k') | net/spdy/hpack_encoder_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698