Overview
Features
Download
Documentation
Community
Add-Ons & Services

HTTPSClient tutorial?

Please post support and help requests here.

HTTPSClient tutorial?

Postby proteneer » 26 Jan 2014, 05:01

OK I've been struggling with HTTPSClient for a while. Do I need to use a context? If I don't pass in a context I just get an illegal state error:

Code: Select all
#include <iostream>
#include <Poco/Net/HTTPSClientSession.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPResponse.h>
#include <Poco/URI.h>
#include <Poco/Crypto/OpenSSLInitializer.h>
#include <Poco/Net/Context.h>

using namespace std;
using namespace Poco::Net;
using namespace Poco;

int main() {

    Poco::Net::initializeSSL();
    Poco::Crypto::OpenSSLInitializer::initialize();

    try {
        HTTPSClientSession session("mail.google.com", 443); // throws Illegal state

        HTTPRequest request("GET", "/");
        session.sendRequest(request);
        HTTPResponse response;
        session.receiveResponse(response);
        cout << response.getStatus() << endl;
    } catch(exception &e) {
        cout << e.what() << endl;
    }

}

proteneer
 
Posts: 1
Joined: 26 Jan 2014, 04:57

Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron