How to use Poco C ++ HTTPSessionFactory

What is the best, easiest way to configure an HTTPSessionFactory to handle HTTP and HTTPS? I know that I need to use HTTPSessionInstantiators, but I really could use a short and sweet example. Thanks.

+4
source share
1 answer

You need to register the http and https protocols.

And for handling "https" you also need to configure SSLManager with a certificate and context, here is an example code snippet:

//register http and https HTTPSessionFactory::defaultFactory().registerProtocol("http", new HTTPSessionInstantiator); HTTPSessionFactory::defaultFactory().registerProtocol("https", new HTTPSSessionInstantiator); //prepare for SSLManager SharedPtr ptrCert = new AcceptCertificateHandler(false); const Poco::Net::Context::Ptr context = new Context(Context::CLIENT_USE, "", "", "", Context::VERIFY_NONE, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); SSLManager::instance().initializeClient(0, ptrCert, context); // now you have the HTTP(S)ClientSession HTTPClientSession *session = HTTPSessionFactory::defaultFactory().createClientSession(uri); 
+3
source

All Articles