diff --git a/HTTPProxy.cpp b/HTTPProxy.cpp index db58d1dc..9dd2cc87 100644 --- a/HTTPProxy.cpp +++ b/HTTPProxy.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -52,7 +51,6 @@ namespace proxy { void AsyncSockRead(); void HTTPRequestFailed(const char *message); void RedirectToJumpService(std::string & host); - void ExtractRequest(); bool ValidateHTTPRequest(); void HandleJumpServices(); bool CreateHTTPRequest(uint8_t *http_buff, std::size_t len); @@ -142,19 +140,6 @@ namespace proxy { m_state = nstate; } - void HTTPReqHandler::ExtractRequest() - { - LogPrint(eLogDebug, "HTTPProxy: request: ", m_method, " ", m_url); - i2p::http::URL url; - url.parse (m_url); - m_address = url.host; - m_port = url.port; - m_path = url.path; - if (url.query.length () > 0) m_path += "?" + url.query; - if (!m_port) m_port = 80; - LogPrint(eLogDebug, "HTTPProxy: server: ", m_address, ", port: ", m_port, ", path: ", m_path); - } - bool HTTPReqHandler::ValidateHTTPRequest() { if ( m_version != "HTTP/1.0" && m_version != "HTTP/1.1" ) @@ -200,7 +185,16 @@ namespace proxy { bool HTTPReqHandler::CreateHTTPRequest(uint8_t *http_buff, std::size_t len) { - ExtractRequest(); //TODO: parse earlier + i2p::http::URL url; + url.parse(m_url); + m_address = url.host; /* < compatibility */ + m_port = url.port; /* < compatibility */ + if (!m_port) { + m_port = (url.schema == "https") ? 443 : 80; + } + url.schema = ""; + url.host = ""; + m_path = url.to_string(); /* < compatibility */ if (!ValidateHTTPRequest()) return false; HandleJumpServices();