| 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_balsa_utils.h" | 5 #include "net/tools/quic/spdy_balsa_utils.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 } | 264 } |
| 265 host_and_port = request_uri->host(); | 265 host_and_port = request_uri->host(); |
| 266 scheme = request_uri->scheme(); | 266 scheme = request_uri->scheme(); |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 DCHECK(!scheme.empty()); | 270 DCHECK(!scheme.empty()); |
| 271 DCHECK(!host_and_port.empty()); | 271 DCHECK(!host_and_port.empty()); |
| 272 DCHECK(!path.empty()); | 272 DCHECK(!path.empty()); |
| 273 | 273 |
| 274 if (scheme.empty()) { |
| 275 if (request_headers.HasHeader("Scheme")) { |
| 276 request_headers.GetAllOfHeaderAsString("Scheme", &scheme); |
| 277 } else { |
| 278 // Requests must contain a :scheme header, and unless another scheme is |
| 279 // detected, https is assumed. |
| 280 scheme = "https"; |
| 281 } |
| 282 } |
| 283 |
| 274 SpdyHeaderBlock block; | 284 SpdyHeaderBlock block; |
| 275 PopulateHttp2RequestHeaderBlock(request_headers, scheme, host_and_port, path, | 285 PopulateHttp2RequestHeaderBlock(request_headers, scheme, host_and_port, path, |
| 276 &block); | 286 &block); |
| 287 |
| 288 // If a "Scheme" header existed in request_headers, it would have been |
| 289 // propagated to |block|. |
| 290 block.erase("scheme"); |
| 277 return block; | 291 return block; |
| 278 } | 292 } |
| 279 | 293 |
| 280 // static | 294 // static |
| 281 SpdyHeaderBlock SpdyBalsaUtils::ResponseHeadersToSpdyHeaders( | 295 SpdyHeaderBlock SpdyBalsaUtils::ResponseHeadersToSpdyHeaders( |
| 282 const BalsaHeaders& response_headers) { | 296 const BalsaHeaders& response_headers) { |
| 283 SpdyHeaderBlock block; | 297 SpdyHeaderBlock block; |
| 284 PopulateSpdyResponseHeaderBlock(HTTP2, response_headers, &block); | 298 PopulateSpdyResponseHeaderBlock(HTTP2, response_headers, &block); |
| 285 return block; | 299 return block; |
| 286 } | 300 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 299 SpdyHeadersToBalsaHeaders(block, headers, true); | 313 SpdyHeadersToBalsaHeaders(block, headers, true); |
| 300 } | 314 } |
| 301 | 315 |
| 302 // static | 316 // static |
| 303 void SpdyBalsaUtils::SpdyHeadersToRequestHeaders(const SpdyHeaderBlock& block, | 317 void SpdyBalsaUtils::SpdyHeadersToRequestHeaders(const SpdyHeaderBlock& block, |
| 304 BalsaHeaders* headers) { | 318 BalsaHeaders* headers) { |
| 305 SpdyHeadersToBalsaHeaders(block, headers, false); | 319 SpdyHeadersToBalsaHeaders(block, headers, false); |
| 306 } | 320 } |
| 307 | 321 |
| 308 } // namespace net | 322 } // namespace net |
| OLD | NEW |