blob: c3c573a9989a00959c45ec33cf6196777f218f06 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// 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.
#ifndef NET_SERVER_HTTP_CONNECTION_H_
#define NET_SERVER_HTTP_CONNECTION_H_
#include <string>
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
namespace net {
class HttpServer;
class StreamListenSocket;
class WebSocket;
class HttpConnection {
public:
~HttpConnection();
void Send(const std::string& data);
void Send(const char* bytes, int len);
void Send200(const std::string& data, const std::string& content_type);
void Send404();
void Send500(const std::string& message);
void Shift(int num_bytes);
const std::string& recv_data() const { return recv_data_; }
int id() const { return id_; }
private:
friend class HttpServer;
static int last_id_;
HttpConnection(HttpServer* server, StreamListenSocket* sock);
void DetachSocket();
HttpServer* server_;
scoped_refptr<StreamListenSocket> socket_;
scoped_ptr<WebSocket> web_socket_;
std::string recv_data_;
int id_;
DISALLOW_COPY_AND_ASSIGN(HttpConnection);
};
} // namespace net
#endif // NET_SERVER_HTTP_CONNECTION_H_
|