Poco::Net

class HTTPSClientSession

Library: NetSSL_OpenSSL
Package: HTTPSClient
Header: Poco/Net/HTTPSClientSession.h

Description

This class implements the client-side of a HTTPS session.

To send a HTTPS request to a HTTPS server, first instantiate a HTTPSClientSession object and specify the server's host name and port number.

Then create a HTTPRequest object, fill it accordingly, and pass it as argument to the sendRequest() method.

sendRequest() will return an output stream that can be used to send the request body, if there is any.

After you are done sending the request body, create a HTTPResponse object and pass it to receiveResponse().

This will return an input stream that can be used to read the response body.

See RFC 2616 <http://www.faqs.org/rfcs/rfc2616.html> for more information about the HTTP protocol.

Note that sending requests that neither contain a content length field in the header nor are using chunked transfer encoding will result in a SSL protocol violation, as the framework shuts down the socket after sending the message body. No orderly SSL shutdown will be performed in this case.

If session caching has been enabled for the Context object passed to the HTTPSClientSession, the HTTPSClientSession class will attempt to reuse a previously obtained Session object in case of a reconnect.

Inheritance

Direct Base Classes: HTTPClientSession

All Base Classes: HTTPClientSession, HTTPSession

Member Summary

Member Functions: abort, connect, proxyAuthenticate, proxyRequestPrefix, read, secure, serverCertificate, sslSession

Inherited Functions: abort, attachSessionData, attachSocket, buffered, bypassProxy, clearException, close, connect, connected, detachSocket, drainBuffer, flushRequest, get, getConnectTimeout, getGlobalProxyConfig, getHost, getKeepAlive, getKeepAliveTimeout, getPort, getProxyConfig, getProxyHost, getProxyPassword, getProxyPort, getProxyUsername, getReceiveTimeout, getSendTimeout, getSourceAddress, getSourceAddress4, getSourceAddress6, getTimeout, mustReconnect, networkException, peek, peekResponse, proxyAuthenticate, proxyAuthenticateDigest, proxyAuthenticateImpl, proxyAuthenticateNTLM, proxyConnect, proxyRequestPrefix, proxyTunnel, read, receive, receiveResponse, reconnect, refill, requestTrailer, reset, responseTrailer, secure, sendChallengeRequest, sendRequest, sendRequestImpl, sessionData, setConnectTimeout, setException, setGlobalProxyConfig, setHost, setKeepAlive, setKeepAliveTimeout, setPort, setProxy, setProxyConfig, setProxyCredentials, setProxyHost, setProxyPassword, setProxyPort, setProxyUsername, setReceiveTimeout, setSendTimeout, setSourceAddress, setTimeout, socket, write

Enumerations

Anonymous

HTTPS_PORT = 443

Constructors

HTTPSClientSession

HTTPSClientSession();

Creates an unconnected HTTPSClientSession.

HTTPSClientSession

explicit HTTPSClientSession(
    const SecureStreamSocket & socket
);

Creates a HTTPSClientSession using the given socket. The socket must not be connected. The session takes ownership of the socket.

HTTPSClientSession

explicit HTTPSClientSession(
    Context::Ptr pContext
);

Creates an unconnected HTTPSClientSession, using the give SSL context.

HTTPSClientSession

HTTPSClientSession(
    const SecureStreamSocket & socket,
    Session::Ptr pSession
);

Creates a HTTPSClientSession using the given socket. The socket must not be connected. The session takes ownership of the socket.

The given Session is reused, if possible (client session caching is enabled for the given Context, and the server agrees to reuse the session).

HTTPSClientSession

HTTPSClientSession(
    const std::string & host,
    Poco::UInt16 port = HTTPS_PORT
);

Creates a HTTPSClientSession using the given host and port.

HTTPSClientSession

HTTPSClientSession(
    Context::Ptr pContext,
    Session::Ptr pSession
);

Creates an unconnected HTTPSClientSession, using the give SSL context.

The given Session is reused, if possible (client session caching is enabled for the given Context, and the server agrees to reuse the session).

HTTPSClientSession

HTTPSClientSession(
    const std::string & host,
    Poco::UInt16 port,
    Context::Ptr pContext
);

Creates a HTTPSClientSession using the given host and port, using the given SSL context.

HTTPSClientSession

HTTPSClientSession(
    const std::string & host,
    Poco::UInt16 port,
    Context::Ptr pContext,
    Session::Ptr pSession
);

Creates a HTTPSClientSession using the given host and port, using the given SSL context.

The given Session is reused, if possible (client session caching is enabled for the given Context, and the server agrees to reuse the session).

Destructor

~HTTPSClientSession virtual

~HTTPSClientSession();

Destroys the HTTPSClientSession and closes the underlying socket.

Member Functions

abort virtual

void abort();

secure virtual

bool secure() const;

Return true iff the session uses SSL or TLS, or false otherwise.

serverCertificate

X509Certificate serverCertificate();

Returns the server's certificate.

The certificate is available after the first request has been sent.

sslSession

Session::Ptr sslSession();

Returns the SSL Session object for the current connection, if session caching has been enabled for the HTTPSClientSession's Context. A null pointer is returned otherwise.

The Session object can be obtained after the first request has been sent.

connect protected virtual

void connect(
    const SocketAddress & address
);

proxyAuthenticate protected virtual

void proxyAuthenticate(
    HTTPRequest & request
);

proxyRequestPrefix protected virtual

std::string proxyRequestPrefix() const;

read protected virtual

int read(
    char * buffer,
    std::streamsize length
);