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

Unified Diff: net/tools/fetch/http_session.cc

Issue 99333: A utility driver for doing client/server HTTP transaction... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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
« no previous file with comments | « net/tools/fetch/http_session.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/fetch/http_session.cc
===================================================================
--- net/tools/fetch/http_session.cc (revision 0)
+++ net/tools/fetch/http_session.cc (revision 0)
@@ -0,0 +1,34 @@
+// Copyright (c) 2009 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)
+ : ALLOW_THIS_IN_INITIALIZER_LIST(
+ socket_(HttpListenSocket::Listen(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.
+ static 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);
+}
« no previous file with comments | « net/tools/fetch/http_session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698