Chromium Code Reviews| Index: net/quic/http_request_line.cc |
| diff --git a/net/quic/http_request_line.cc b/net/quic/http_request_line.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bf388330af056e63134f7218a7b46d60d097b830 |
| --- /dev/null |
| +++ b/net/quic/http_request_line.cc |
| @@ -0,0 +1,58 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "net/quic/http_request_line.h" |
| +#include "net/quic/string_piece_utils.h" |
| + |
| +using std::string; |
| +using base::StringPiece; |
| +using net::StringPieceUtils; |
| +using net::SpdyHeaderBlock; |
| + |
| +HttpRequestLine::HttpRequestLine(StringPiece method, |
|
Ryan Hamilton
2014/06/19 00:15:44
I agree that HttpRequestInfo does not add a ton of
dmz
2014/06/19 21:17:02
You're right, I think I had seen only HttpRequestH
|
| + StringPiece path, |
| + StringPiece version, |
| + StringPiece host) |
| + : method_(method.as_string()), |
| + path_(path.as_string()), |
| + version_(version.as_string()), |
| + host_(host.as_string()) { |
| +} |
| + |
| +HttpRequestLine::~HttpRequestLine() { |
| +} |
| + |
| +// static |
| +HttpRequestLine* HttpRequestLine::FromSpdyHeaders( |
| + const SpdyHeaderBlock& headers) { |
| + typedef SpdyHeaderBlock::const_iterator BlockIt; |
| + |
| + BlockIt host_it = headers.find(":host"); |
| + BlockIt path_it = headers.find(":path"); |
| + BlockIt method_it = headers.find(":method"); |
| + BlockIt end_it = headers.end(); |
| + if (host_it == end_it || path_it == end_it || method_it == end_it) { |
| + return NULL; |
| + } |
| + return new HttpRequestLine(method_it->second, |
| + path_it->second, |
| + "HTTP/1.1", |
| + host_it->second); |
| +} |
| + |
| +string HttpRequestLine::FullPath() const { |
| + StringPiece uri = path_; |
| + if (uri.size() == 0) { |
| + return ""; |
| + } |
| + StringPiece host; |
| + if (uri[0] == '/') { |
| + host = host_; |
| + } else if (StringPieceUtils::StartsWithIgnoreCase(uri, "https://")) { |
| + uri.remove_prefix(8); |
| + } else if (StringPieceUtils::StartsWithIgnoreCase(uri, "http://")) { |
| + uri.remove_prefix(7); |
| + } |
| + return host.as_string() + uri.as_string(); |
| +} |