summaryrefslogtreecommitdiff
path: root/chromium/net/tools/fetch/http_session.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/net/tools/fetch/http_session.cc')
-rw-r--r--chromium/net/tools/fetch/http_session.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/chromium/net/tools/fetch/http_session.cc b/chromium/net/tools/fetch/http_session.cc
new file mode 100644
index 00000000000..d9e991b798a
--- /dev/null
+++ b/chromium/net/tools/fetch/http_session.cc
@@ -0,0 +1,33 @@
+// 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/tools/fetch/http_session.h"
+#include "net/tools/fetch/http_server_response_info.h"
+
+HttpSession::HttpSession(const std::string& ip, int port)
+ : socket_(HttpListenSocket::CreateAndListen(ip, port, this)) {
+}
+
+HttpSession::~HttpSession() {
+}
+
+void HttpSession::OnRequest(HttpListenSocket* connection,
+ HttpServerRequestInfo* info) {
+ // TODO(mbelshe): Make this function more interesting.
+
+ // Generate a 10KB sequence of data.
+ CR_DEFINE_STATIC_LOCAL(std::string, data, ());
+ if (data.length() == 0) {
+ while (data.length() < (10 * 1024))
+ data += 'a' + (rand() % 26);
+ }
+
+ HttpServerResponseInfo response_info;
+ response_info.protocol = "HTTP/1.1";
+ response_info.status = 200;
+ response_info.content_type = "text/plain";
+ response_info.content_length = data.length();
+
+ connection->Respond(&response_info, data);
+}