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

Side by Side Diff: net/tools/fetch/http_session.cc

Issue 10161005: Add DefaultListenSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build on Windows Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/tools/fetch/http_server.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/fetch/http_session.h" 5 #include "net/tools/fetch/http_session.h"
6 #include "net/tools/fetch/http_server_response_info.h" 6 #include "net/tools/fetch/http_server_response_info.h"
7 7
8 HttpSession::HttpSession(const std::string& ip, int port) 8 HttpSession::HttpSession(const std::string& ip, int port)
9 : ALLOW_THIS_IN_INITIALIZER_LIST( 9 : ALLOW_THIS_IN_INITIALIZER_LIST(
10 socket_(HttpListenSocket::Listen(ip, port, this))) { 10 socket_(HttpListenSocket::CreateAndListen(ip, port, this))) {
11 } 11 }
12 12
13 HttpSession::~HttpSession() { 13 HttpSession::~HttpSession() {
14 } 14 }
15 15
16 void HttpSession::OnRequest(HttpListenSocket* connection, 16 void HttpSession::OnRequest(HttpListenSocket* connection,
17 HttpServerRequestInfo* info) { 17 HttpServerRequestInfo* info) {
18 // TODO(mbelshe): Make this function more interesting. 18 // TODO(mbelshe): Make this function more interesting.
19 19
20 // Generate a 10KB sequence of data. 20 // Generate a 10KB sequence of data.
21 CR_DEFINE_STATIC_LOCAL(std::string, data, ()); 21 CR_DEFINE_STATIC_LOCAL(std::string, data, ());
22 if (data.length() == 0) { 22 if (data.length() == 0) {
23 while (data.length() < (10 * 1024)) 23 while (data.length() < (10 * 1024))
24 data += 'a' + (rand() % 26); 24 data += 'a' + (rand() % 26);
25 } 25 }
26 26
27 HttpServerResponseInfo response_info; 27 HttpServerResponseInfo response_info;
28 response_info.protocol = "HTTP/1.1"; 28 response_info.protocol = "HTTP/1.1";
29 response_info.status = 200; 29 response_info.status = 200;
30 response_info.content_type = "text/plain"; 30 response_info.content_type = "text/plain";
31 response_info.content_length = data.length(); 31 response_info.content_length = data.length();
32 32
33 connection->Respond(&response_info, data); 33 connection->Respond(&response_info, data);
34 } 34 }
OLDNEW
« no previous file with comments | « net/tools/fetch/http_server.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698