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

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

Issue 1692253004: QUIC - chromium server push support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review feedback round 2. Created 4 years, 9 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/spdy_http_utils.h ('k') | no next file » | 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) 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_http_utils.h" 5 #include "net/spdy/spdy_http_utils.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "net/base/escape.h" 13 #include "net/base/escape.h"
13 #include "net/base/load_flags.h" 14 #include "net/base/load_flags.h"
14 #include "net/base/url_util.h" 15 #include "net/base/url_util.h"
15 #include "net/http/http_request_headers.h" 16 #include "net/http/http_request_headers.h"
16 #include "net/http/http_request_info.h" 17 #include "net/http/http_request_info.h"
17 #include "net/http/http_response_headers.h" 18 #include "net/http/http_response_headers.h"
18 #include "net/http/http_response_info.h" 19 #include "net/http/http_response_info.h"
19 #include "net/http/http_util.h" 20 #include "net/http/http_util.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 186
186 NET_EXPORT_PRIVATE RequestPriority ConvertSpdyPriorityToRequestPriority( 187 NET_EXPORT_PRIVATE RequestPriority ConvertSpdyPriorityToRequestPriority(
187 SpdyPriority priority, 188 SpdyPriority priority,
188 SpdyMajorVersion protocol_version) { 189 SpdyMajorVersion protocol_version) {
189 // Handle invalid values gracefully. 190 // Handle invalid values gracefully.
190 // Note that SpdyPriority is not an enum, hence the magic constants. 191 // Note that SpdyPriority is not an enum, hence the magic constants.
191 return (priority >= 5) ? 192 return (priority >= 5) ?
192 IDLE : static_cast<RequestPriority>(4 - priority); 193 IDLE : static_cast<RequestPriority>(4 - priority);
193 } 194 }
194 195
196 NET_EXPORT_PRIVATE void ConvertHeaderBlockToHttpRequestHeaders(
197 const SpdyHeaderBlock& spdy_headers,
198 HttpRequestHeaders* http_headers) {
199 for (const auto& it : spdy_headers) {
200 base::StringPiece key = it.first;
201 if (key[0] == ':') {
202 key.remove_prefix(1);
203 }
204 std::vector<base::StringPiece> values = base::SplitStringPiece(
205 it.second, "\0", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
206 for (const auto& value : values) {
207 http_headers->SetHeader(key, value);
208 }
209 }
210 }
211
195 GURL GetUrlFromHeaderBlock(const SpdyHeaderBlock& headers, 212 GURL GetUrlFromHeaderBlock(const SpdyHeaderBlock& headers,
196 SpdyMajorVersion protocol_version) { 213 SpdyMajorVersion protocol_version) {
197 SpdyHeaderBlock::const_iterator it = headers.find(":scheme"); 214 SpdyHeaderBlock::const_iterator it = headers.find(":scheme");
198 if (it == headers.end()) 215 if (it == headers.end())
199 return GURL(); 216 return GURL();
200 std::string url = it->second.as_string(); 217 std::string url = it->second.as_string();
201 url.append("://"); 218 url.append("://");
202 219
203 it = headers.find(protocol_version >= HTTP2 ? ":authority" : ":host"); 220 it = headers.find(protocol_version >= HTTP2 ? ":authority" : ":host");
204 if (it == headers.end()) 221 if (it == headers.end())
205 return GURL(); 222 return GURL();
206 url.append(it->second.as_string()); 223 url.append(it->second.as_string());
207 224
208 it = headers.find(":path"); 225 it = headers.find(":path");
209 if (it == headers.end()) 226 if (it == headers.end())
210 return GURL(); 227 return GURL();
211 url.append(it->second.as_string()); 228 url.append(it->second.as_string());
212 return GURL(url); 229 return GURL(url);
213 } 230 }
214 231
215 } // namespace net 232 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_http_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698