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

Unified Diff: net/quic/http_request_line.cc

Issue 337093003: QuicServer: Use Chrome's header parsing rather than Balsa (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@quic_server_3
Patch Set: (mark StringPieceUtils as copied, not added) Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
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();
+}

Powered by Google App Engine
This is Rietveld 408576698