summaryrefslogtreecommitdiff
path: root/http_connection.h
blob: b6d6e2762234c86ea98230d94bde92ea4c263840 (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
#ifndef HTTP_CONNECTION_H
#define HTTP_CONNECTION_H

#include <string>
#include <vector>
#include <map>

#include <boost/asio.hpp>
#include <boost/enable_shared_from_this.hpp>
using boost::asio::ip::tcp;

namespace HTTP {
	class Connection : public boost::enable_shared_from_this<Connection> {
		friend class Server;
		
		private:
			Connection(boost::asio::io_service& io_service);
			void handle_write(const boost::system::error_code& error, size_t bytes_transferred);
			void handle_read(const boost::system::error_code& error, size_t bytes_transferred);
			tcp::socket socket;
			boost::asio::streambuf buf;
			
			//! Request method.
			std::string method;
			
			//! Request path.
			std::vector<std::string> path;
			
			//! Request arguments.
			std::map<std::string, std::string> args;
			
			//! Request version.
			std::string version;
			
			//! Request headers.
			std::map<std::string, std::string> headers;
			
			
			//! Parse request headers.
			bool parse_request(boost::asio::streambuf& buf);
		
		public:
			typedef boost::shared_ptr<Connection> p;
			
			void start();
	};
};

#endif