17 #include "connectionhttpproxy.h"
31 const std::string& server,
int port )
33 m_logInstance( logInstance ), m_http11( false )
46 const std::string& server,
int port )
48 m_logInstance( logInstance )
74 m_connection = connection;
107 return m_connection && m_connection->
send( data );
123 totalIn = totalOut = 0;
127 const std::string& data )
134 m_proxyHandshakeBuffer += data;
135 if( ( !m_proxyHandshakeBuffer.compare( 0, 12,
"HTTP/1.0 200" )
136 || !m_proxyHandshakeBuffer.compare( 0, 12,
"HTTP/1.1 200" ) )
137 && !m_proxyHandshakeBuffer.compare( m_proxyHandshakeBuffer.length() - 4, 4,
"\r\n\r\n" ) )
142 "HTTP proxy connection established" );
145 else if( !m_proxyHandshakeBuffer.compare( 9, 3,
"407" ) )
150 else if( !m_proxyHandshakeBuffer.compare( 9, 3,
"403" )
151 || !m_proxyHandshakeBuffer.compare( 9, 3,
"404" ) )
170 if( !servers.empty() )
172 const std::pair< std::string, int >& host = *servers.begin();
177 std::string message =
"Requesting HTTP proxy connection to " + server +
":"
178 + util::int2string( port );
181 std::string os =
"CONNECT " + server +
":" + util::int2string( port ) +
" HTTP/1."
182 + util::int2string( m_http11 ? 1 : 0 ) +
"\r\n"
183 "Host: " + server +
"\r\n"
184 "Content-Length: 0\r\n"
185 "Proxy-Connection: Keep-Alive\r\n"
186 "Pragma: no-cache\r\n"
189 if( !m_proxyUser.empty() && !m_proxyPwd.empty() )
191 os +=
"Proxy-Authorization: Basic " +
Base64::encode64( m_proxyUser +
":" + m_proxyPwd )
196 if( !m_connection->
send( os ) )