class Poco::Net::HTTPStreamFactory

Overview

An implementation of the URIStreamFactory interface that handles Hyper-Text Transfer Protocol (http) URIs. Moreā€¦

#include <HTTPStreamFactory.h>

class HTTPStreamFactory: public Poco::URIStreamFactory
{
public:
    // construction

    HTTPStreamFactory();

    HTTPStreamFactory(
        const std::string& proxyHost,
        Poco::UInt16 proxyPort = HTTPSession::HTTP_PORT
        );

    HTTPStreamFactory(
        const std::string& proxyHost,
        Poco::UInt16 proxyPort,
        const std::string& proxyUsername,
        const std::string& proxyPassword
        );

    // methods

    virtual
    std::istream*
    open(const Poco::URI& uri);

    static
    void
    registerFactory();

    static
    void
    unregisterFactory();
};

Inherited Members

public:
    // methods

    virtual
    std::istream*
    open(const URI& uri) = 0;

Detailed Documentation

An implementation of the URIStreamFactory interface that handles Hyper-Text Transfer Protocol (http) URIs.

Construction

HTTPStreamFactory()

Creates the HTTPStreamFactory.

HTTPStreamFactory(
    const std::string& proxyHost,
    Poco::UInt16 proxyPort = HTTPSession::HTTP_PORT
    )

Creates the HTTPStreamFactory.

HTTP connections will use the given proxy.

HTTPStreamFactory(
    const std::string& proxyHost,
    Poco::UInt16 proxyPort,
    const std::string& proxyUsername,
    const std::string& proxyPassword
    )

Creates the HTTPStreamFactory.

HTTP connections will use the given proxy and will be authorized against the proxy using Basic authentication with the given proxyUsername and proxyPassword.

Methods

virtual
std::istream*
open(const Poco::URI& uri)

Creates and opens a HTTP stream for the given URI.

The URI must be a http://... URI.

Throws a NetException if anything goes wrong.

Redirect responses are handled and the redirect location is automatically resolved, as long as the redirect location is still accessible via the HTTP protocol. If a redirection to a non http://... URI is received, a UnsupportedRedirectException exception is thrown. The offending URI can then be obtained via the message() method of UnsupportedRedirectException.

static
void
registerFactory()

Registers the HTTPStreamFactory with the default URIStreamOpener instance.

static
void
unregisterFactory()

Unregisters the HTTPStreamFactory with the default URIStreamOpener instance.