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

Side by Side Diff: net/tools/fetch/http_listen_socket.h

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, 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/fetch_server.cc ('k') | net/tools/fetch/http_listen_socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_BASE_TOOLS_HTTP_LISTEN_SOCKET_H_
6 #define NET_BASE_TOOLS_HTTP_LISTEN_SOCKET_H_
7
8 #include "base/message_loop.h"
9 #include "net/base/listen_socket.h"
10
11 class HttpServerRequestInfo;
12 class HttpServerResponseInfo;
13
14 // Implements a simple HTTP listen socket on top of the raw socket interface.
15 class HttpListenSocket : public ListenSocket,
16 public ListenSocket::ListenSocketDelegate {
17 public:
18 class Delegate {
19 public:
20 virtual void OnRequest(HttpListenSocket* connection,
21 HttpServerRequestInfo* info) = 0;
22 };
23
24 static HttpListenSocket* Listen(const std::string& ip, int port,
25 HttpListenSocket::Delegate* delegate);
26 virtual ~HttpListenSocket();
27
28 void Listen() { ListenSocket::Listen(); }
29 virtual void Accept();
30
31 // Send a server response.
32 // TODO(mbelshe): make this capable of non-ascii data.
33 void Respond(HttpServerResponseInfo* info, std::string& data);
34
35 // ListenSocketDelegate
36 virtual void DidAccept(ListenSocket* server, ListenSocket* connection);
37 virtual void DidRead(ListenSocket* connection, const std::string& data);
38 virtual void DidClose(ListenSocket* sock);
39
40 private:
41 static const int kReadBufSize = 16 * 1024;
42 HttpListenSocket(SOCKET s, HttpListenSocket::Delegate* del);
43
44 // Expects the raw data to be stored in recv_data_. If parsing is successful,
45 // will remove the data parsed from recv_data_, leaving only the unused
46 // recv data.
47 HttpServerRequestInfo* ParseHeaders();
48
49 HttpListenSocket::Delegate* delegate_;
50 std::string recv_data_;
51
52 DISALLOW_EVIL_CONSTRUCTORS(HttpListenSocket);
53 };
54
55 #endif // NET_BASE_TOOLS_HTTP_LISTEN_SOCKET_H_
OLDNEW
« no previous file with comments | « net/tools/fetch/fetch_server.cc ('k') | net/tools/fetch/http_listen_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698