2014-03-17 22:31:29 +00:00
|
|
|
#ifndef HTTP_PROXY_H__
|
|
|
|
#define HTTP_PROXY_H__
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include <thread>
|
|
|
|
#include <boost/asio.hpp>
|
|
|
|
#include <boost/array.hpp>
|
|
|
|
|
2014-03-29 22:16:23 +00:00
|
|
|
#include "HTTPServer.h"
|
|
|
|
|
2014-03-17 22:31:29 +00:00
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace proxy
|
|
|
|
{
|
2014-03-29 22:16:23 +00:00
|
|
|
class HTTPProxyConnection : public i2p::util::HTTPConnection
|
2014-03-17 22:31:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-03-29 22:16:23 +00:00
|
|
|
HTTPProxyConnection (boost::asio::ip::tcp::socket * socket): HTTPConnection(socket) { };
|
2014-03-17 22:31:29 +00:00
|
|
|
|
2014-03-29 22:16:23 +00:00
|
|
|
protected:
|
|
|
|
void RunRequest();
|
2014-03-17 22:31:29 +00:00
|
|
|
void parseHeaders(const std::string& h, std::vector<header>& hm);
|
2014-03-29 22:16:23 +00:00
|
|
|
void ExtractRequest(request &m_Request);
|
|
|
|
};
|
2014-03-17 22:31:29 +00:00
|
|
|
|
2014-03-29 22:16:23 +00:00
|
|
|
class HTTPProxy : public i2p::util::HTTPServer
|
2014-03-17 22:31:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-03-29 22:16:23 +00:00
|
|
|
HTTPProxy (int port): HTTPServer(port) {};
|
2014-03-17 22:31:29 +00:00
|
|
|
|
|
|
|
private:
|
2014-03-29 22:16:23 +00:00
|
|
|
void CreateConnection(boost::asio::ip::tcp::socket * m_NewSocket)
|
|
|
|
{
|
|
|
|
new HTTPProxyConnection(m_NewSocket);
|
|
|
|
}
|
|
|
|
};
|
2014-03-17 22:31:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|