class Poco::Net::HTTPServerRequest

Overview

This abstract subclass of HTTPRequest is used for representing server-side HTTP requests. More…

#include <HTTPServerRequest.h>

class HTTPServerRequest: public Poco::Net::HTTPRequest
{
public:
    // methods

    virtual
    std::istream&
    stream() = 0;

    virtual
    bool
    expectContinue() const = 0;

    virtual
    const SocketAddress&
    clientAddress() const = 0;

    virtual
    const SocketAddress&
    serverAddress() const = 0;

    virtual
    const HTTPServerParams&
    serverParams() const = 0;

    virtual
    HTTPServerResponse&
    response() const = 0;
};

// direct descendants

class HTTPServerRequestImpl;

Inherited Members

public:
    // typedefs

    typedef Poco::ListMap<std::string, std::string> HeaderMap;
    typedef HeaderMap::Iterator Iterator;
    typedef HeaderMap::ConstIterator ConstIterator;

    // fields

    static const std::string HTTP_1_0;
    static const std::string HTTP_1_1;
    static const std::string IDENTITY_TRANSFER_ENCODING;
    static const std::string CHUNKED_TRANSFER_ENCODING;
    static const int UNKNOWN_CONTENT_LENGTH;
    static const std::string UNKNOWN_CONTENT_TYPE;
    static const std::string CONTENT_LENGTH;
    static const std::string CONTENT_TYPE;
    static const std::string TRANSFER_ENCODING;
    static const std::string CONNECTION;
    static const std::string CONNECTION_KEEP_ALIVE;
    static const std::string CONNECTION_CLOSE;
    static const std::string EMPTY;
    static const std::string HTTP_GET;
    static const std::string HTTP_HEAD;
    static const std::string HTTP_PUT;
    static const std::string HTTP_POST;
    static const std::string HTTP_OPTIONS;
    static const std::string HTTP_DELETE;
    static const std::string HTTP_TRACE;
    static const std::string HTTP_CONNECT;
    static const std::string HTTP_PATCH;
    static const std::string HOST;
    static const std::string COOKIE;
    static const std::string AUTHORIZATION;
    static const std::string PROXY_AUTHORIZATION;
    static const std::string UPGRADE;

    // methods

    NameValueCollection&
    operator=(const NameValueCollection& nvc);

    void
    swap(NameValueCollection& nvc);

    const std::string&
    operator[](const std::string& name) const;

    void
    set(
        const std::string& name,
        const std::string& value
        );

    void
    add(
        const std::string& name,
        const std::string& value
        );

    const std::string&
    get(const std::string& name) const;

    const std::string&
    get(
        const std::string& name,
        const std::string& defaultValue
        ) const;

    bool
    has(const std::string& name) const;

    ConstIterator
    find(const std::string& name) const;

    ConstIterator
    begin() const;

    ConstIterator
    end() const;

    bool
    empty() const;

    std::size_t
    size() const;

    void
    erase(const std::string& name);

    void
    clear();

    MessageHeader&
    operator=(const MessageHeader& messageHeader);

    virtual
    void
    write(std::ostream& ostr) const;

    virtual
    void
    read(std::istream& istr);

    int
    getFieldLimit() const;

    void
    setFieldLimit(int limit);

    bool
    hasToken(
        const std::string& fieldName,
        const std::string& token
        ) const;

    static
    void
    splitElements(
        const std::string& s,
        std::vector<std::string>& elements,
        bool ignoreEmpty = true
        );

    static
    void
    splitParameters(
        const std::string& s,
        std::string& value,
        NameValueCollection& parameters
        );

    static
    void
    splitParameters(
        const std::string::const_iterator& begin,
        const std::string::const_iterator& end,
        NameValueCollection& parameters
        );

    static
    void
    quote(
        const std::string& value,
        std::string& result,
        bool allowSpace = false
        );

    void
    setVersion(const std::string& version);

    const std::string&
    getVersion() const;

    void
    setContentLength(std::streamsize length);

    std::streamsize
    getContentLength() const;

    bool
    hasContentLength() const;

    void
    setTransferEncoding(const std::string& transferEncoding);

    const std::string&
    getTransferEncoding() const;

    void
    setChunkedTransferEncoding(bool flag);

    bool
    getChunkedTransferEncoding() const;

    void
    setContentType(const std::string& mediaType);

    void
    setContentType(const MediaType& mediaType);

    const std::string&
    getContentType() const;

    void
    setKeepAlive(bool keepAlive);

    bool
    getKeepAlive() const;

    void
    setMethod(const std::string& method);

    const std::string&
    getMethod() const;

    void
    setURI(const std::string& uri);

    const std::string&
    getURI() const;

    void
    setHost(const std::string& host);

    void
    setHost(
        const std::string& host,
        Poco::UInt16 port
        );

    const std::string&
    getHost() const;

    void
    setCookies(const NameValueCollection& cookies);

    void
    getCookies(NameValueCollection& cookies) const;

    bool
    hasCredentials() const;

    void
    getCredentials(
        std::string& scheme,
        std::string& authInfo
        ) const;

    void
    setCredentials(
        const std::string& scheme,
        const std::string& authInfo
        );

    bool
    hasProxyCredentials() const;

    void
    getProxyCredentials(
        std::string& scheme,
        std::string& authInfo
        ) const;

    void
    setProxyCredentials(
        const std::string& scheme,
        const std::string& authInfo
        );

    virtual
    void
    write(std::ostream& ostr) const;

    virtual
    void
    read(std::istream& istr);

protected:
    // methods

    void
    getCredentials(
        const std::string& header,
        std::string& scheme,
        std::string& authInfo
        ) const;

    void
    setCredentials(
        const std::string& header,
        const std::string& scheme,
        const std::string& authInfo
        );

Detailed Documentation

This abstract subclass of HTTPRequest is used for representing server-side HTTP requests.

A HTTPServerRequest is passed to the handleRequest() method of HTTPRequestHandler.

Construction

~HTTPServerRequest()

Destroys the HTTPServerRequest.

Methods

virtual
std::istream&
stream() = 0

Returns the input stream for reading the request body.

The stream must be valid until the HTTPServerRequest object is destroyed.

virtual
bool
expectContinue() const = 0

Returns true if the client expects a 100 Continue response.

virtual
const SocketAddress&
clientAddress() const = 0

Returns the client’s address.

virtual
const SocketAddress&
serverAddress() const = 0

Returns the server’s address.

virtual
const HTTPServerParams&
serverParams() const = 0

Returns a reference to the server parameters.

virtual
HTTPServerResponse&
response() const = 0

Returns a reference to the associated response.