Browse Source

use m_Response field for HTTP proxy response

pull/503/head
orignal 9 years ago
parent
commit
5ad10955be
  1. 11
      HTTPProxy.cpp

11
HTTPProxy.cpp

@ -56,6 +56,7 @@ namespace proxy
uint8_t m_http_buff[http_buffer_size]; uint8_t m_http_buff[http_buffer_size];
std::shared_ptr<boost::asio::ip::tcp::socket> m_sock; std::shared_ptr<boost::asio::ip::tcp::socket> m_sock;
std::string m_request; //Data left to be sent std::string m_request; //Data left to be sent
std::string m_Response;
std::string m_url; //URL std::string m_url; //URL
std::string m_method; //Method std::string m_method; //Method
std::string m_version; //HTTP version std::string m_version; //HTTP version
@ -107,9 +108,8 @@ namespace proxy
ss << "Content-Length: " << std::to_string(size + 2) << "\r\n" ss << "Content-Length: " << std::to_string(size + 2) << "\r\n"
<< "\r\n"; /* end of headers */ << "\r\n"; /* end of headers */
ss << message << "\r\n"; ss << message << "\r\n";
static std::string response; m_Response = ss.str();
response = ss.str(); boost::asio::async_write(*m_sock, boost::asio::buffer(m_Response),
boost::asio::async_write(*m_sock, boost::asio::buffer(response),
std::bind(&HTTPProxyHandler::SentHTTPFailed, shared_from_this(), std::placeholders::_1)); std::bind(&HTTPProxyHandler::SentHTTPFailed, shared_from_this(), std::placeholders::_1));
} }
@ -120,9 +120,8 @@ namespace proxy
uint16_t httpPort; i2p::config::GetOption("http.port", httpPort); uint16_t httpPort; i2p::config::GetOption("http.port", httpPort);
response << "HTTP/1.1 302 Found\r\nLocation: http://" << httpAddr << ":" << httpPort << "/?page=jumpservices&address=" << m_address << "\r\n\r\n"; response << "HTTP/1.1 302 Found\r\nLocation: http://" << httpAddr << ":" << httpPort << "/?page=jumpservices&address=" << m_address << "\r\n\r\n";
static std::string s; m_Response = response.str ();
s = response.str (); boost::asio::async_write(*m_sock, boost::asio::buffer(m_Response),
boost::asio::async_write(*m_sock, boost::asio::buffer(s),
std::bind(&HTTPProxyHandler::SentHTTPFailed, shared_from_this(), std::placeholders::_1)); std::bind(&HTTPProxyHandler::SentHTTPFailed, shared_from_this(), std::placeholders::_1));
} }

Loading…
Cancel
Save