4

HTTPとHTTPSの両方を処理するようにHTTPSessionFactoryを設定するための最良の最も簡単な方法はどのようになっていますか?HTTPSessionInstantiatorsを使用する必要があることはわかっていますが、短くて甘い例を実際に使用できます。ありがとう。

4

1 に答える 1

3

「http」および「https」プロトコルを登録する必要があります。

また、「https」を処理するには、証明書とコンテキストを使用してSSLManagerを構成する必要もあります。次のコード例を次に示します。

//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);
于 2012-10-02T08:27:32.533 に答える