MCPcopy Create free account
hub / github.com/SpartanJ/eepp / downloadRequest

Method downloadRequest

src/eepp/network/http.cpp:790–1196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

788}
789
790Http::Response Http::downloadRequest( const Http::Request& request, IOStream& writeTo,
791 Time timeout ) {
792 // Solve the host IP only when the request starts.
793 if ( !mHostSolved ) {
794 if ( !mProxy.empty() ) {
795 mHost = IpAddress( mProxy.getHost() );
796 } else {
797 mHost = IpAddress( mHostName );
798 }
799 mHostSolved = true;
800 }
801
802 if ( 0 == mHost.toInteger() ) {
803 return Response();
804 }
805
806 if ( NULL == mConnection ) {
807 HttpConnection* connection = eeNew( HttpConnection, () );
808 TcpSocket* socket = NULL;
809
810 // If the http client is proxied and the end host use SSL
811 // We need to create an HTTP Tunnel against the proxy server
812 if ( isProxied() && mIsSSL && SSLSocket::isSupported() ) {
813 socket = SSLSocket::New( mHostName, request.getValidateCertificate(),
814 request.getValidateHostname() );
815
816 connection->setSSL( true );
817 } else {
818 bool isSSL = !isProxied()
819 ? mIsSSL
820 : ( SSLSocket::isSupported() && mProxy.getScheme() == "https" );
821
822 socket = isSSL ? SSLSocket::New( mHostName, request.getValidateCertificate(),
823 request.getValidateHostname() )
824 : TcpSocket::New();
825
826 connection->setSSL( isSSL );
827 }
828
829 if ( timeout != Time::Zero ) {
830 socket->setReceiveTimeout( timeout );
831 socket->setSendTimeout( timeout );
832 }
833
834 connection->setSocket( socket );
835
836 mConnection = connection;
837 }
838
839 // First make sure that the request is valid -- add missing mandatory fields
840 Request toSend( prepareFields( request ) );
841
842 // Prepare the response
843 Response received;
844
845 if ( request.isCancelled() ) {
846 onCancel( request );
847 endConnection();

Callers 3

requestMethod · 0.80
runMethod · 0.80
mainFunction · 0.80

Calls 15

ResponseClass · 0.85
sendProgressFunction · 0.85
fromStringFunction · 0.85
formatFunction · 0.85
toIntegerMethod · 0.80
setSSLMethod · 0.80
setSocketMethod · 0.80
isConnectedMethod · 0.80
getSocketMethod · 0.80
tcpConnectMethod · 0.80
getPortMethod · 0.80
setConnectedMethod · 0.80

Tested by

no test coverage detected