Poco::Net

class HTTPRequest

Library: Net
Package: HTTP
Header: Poco/Net/HTTPRequest.h

Description

This class encapsulates an HTTP request message.

In addition to the properties common to all HTTP messages, a HTTP request has a method (e.g. GET, HEAD, POST, etc.) and a request URI.

Inheritance

Direct Base Classes: HTTPMessage

All Base Classes: HTTPMessage, MessageHeader, NameValueCollection

Known Derived Classes: HTTPServerRequest, HTTPServerRequestImpl

Member Summary

Member Functions: getCookies, getCredentials, getExpectContinue, getHost, getMethod, getProxyCredentials, getURI, hasCredentials, hasProxyCredentials, operator =, read, removeCredentials, removeProxyCredentials, setCookies, setCredentials, setExpectContinue, setHost, setMethod, setProxyCredentials, setURI, write

Inherited Functions: add, begin, clear, decodeRFC2047, decodeWord, empty, end, erase, find, get, getAutoDecode, getChunkedTransferEncoding, getContentLength, getContentLength64, getContentType, getDecoded, getFieldLimit, getKeepAlive, getNameLengthLimit, getTransferEncoding, getValueLengthLimit, getVersion, has, hasContentLength, hasToken, operator =, operator [], quote, read, secureClear, secureErase, set, setAutoDecode, setChunkedTransferEncoding, setContentLength, setContentLength64, setContentType, setFieldLimit, setKeepAlive, setNameLengthLimit, setTransferEncoding, setValueLengthLimit, setVersion, size, splitElements, splitParameters, swap, write

Constructors

HTTPRequest

HTTPRequest();

Creates a GET / HTTP/1.0 HTTP request.

HTTPRequest

explicit HTTPRequest(
    const std::string & version
);

Creates a GET / HTTP/1.x request with the given version (HTTP/1.0 or HTTP/1.1).

HTTPRequest

HTTPRequest(
    const HTTPRequest & other
);

Creates a HTTP request by copying another one.

HTTPRequest

HTTPRequest(
    const std::string & method,
    const std::string & uri
);

Creates a HTTP/1.0 request with the given method and URI.

HTTPRequest

HTTPRequest(
    const std::string & method,
    const std::string & uri,
    const std::string & version
);

Creates a HTTP request with the given method, URI and version.

Destructor

~HTTPRequest virtual

virtual ~HTTPRequest();

Destroys the HTTPRequest.

Member Functions

getCookies

void getCookies(
    NameValueCollection & cookies
) const;

Fills cookies with the cookies extracted from the Cookie headers in the request.

getCredentials

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

Returns the authentication scheme and additional authentication information contained in this request.

Throws a NotAuthenticatedException if no authentication information is contained in the request.

getExpectContinue

bool getExpectContinue() const;

Returns true if the request contains an "Expect: 100-continue" header.

getHost

const std::string & getHost() const;

Returns the value of the Host header field.

Throws a NotFoundException if the request does not have a Host header field.

getMethod inline

const std::string & getMethod() const;

Returns the method.

getProxyCredentials

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

Returns the proxy authentication scheme and additional proxy authentication information contained in this request.

Throws a NotAuthenticatedException if no proxy authentication information is contained in the request.

getURI inline

const std::string & getURI() const;

Returns the request URI.

hasCredentials

bool hasCredentials() const;

Returns true iff the request contains authentication information in the form of an Authorization header.

hasProxyCredentials

bool hasProxyCredentials() const;

Returns true iff the request contains proxy authentication information in the form of an Proxy-Authorization header.

operator =

HTTPRequest & operator = (
    const HTTPRequest & param418
);

Assignment operator.

read virtual

void read(
    std::istream & istr
);

Reads the HTTP request from the given input stream.

removeCredentials

void removeCredentials();

Removes any credentials from the request.

removeProxyCredentials

void removeProxyCredentials();

Removes any proxy credentials from the request.

setCookies

void setCookies(
    const NameValueCollection & cookies
);

Adds a Cookie header with the names and values from cookies.

setCredentials

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

Sets the authentication scheme and information for this request.

setExpectContinue

void setExpectContinue(
    bool expectContinue
);

Adds a "Expect: 100-continue" header to the request if expectContinue is true, otherwise removes the Expect header.

setHost

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

Sets the value of the Host header field.

setHost

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

Sets the value of the Host header field.

If the given port number is a non-standard port number (other than 80 or 443), it is included in the Host header field.

setMethod

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

Sets the method.

setProxyCredentials

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

Sets the proxy authentication scheme and information for this request.

setURI

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

Sets the request URI.

write virtual

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

Writes the HTTP request to the given output stream.

getCredentials protected

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

Returns the authentication scheme and additional authentication information contained in the given header of request.

Throws a NotAuthenticatedException if no authentication information is contained in the request.

setCredentials protected

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

Writes the authentication scheme and information for this request to the given header.

Variables

AUTHORIZATION static

static const std::string AUTHORIZATION;

COOKIE static

static const std::string COOKIE;

EXPECT static

static const std::string EXPECT;

HOST static

static const std::string HOST;

HTTP_CONNECT static

static const std::string HTTP_CONNECT;

HTTP_DELETE static

static const std::string HTTP_DELETE;

HTTP_GET static

static const std::string HTTP_GET;

HTTP_HEAD static

static const std::string HTTP_HEAD;

HTTP_OPTIONS static

static const std::string HTTP_OPTIONS;

HTTP_PATCH static

static const std::string HTTP_PATCH;

HTTP_POST static

static const std::string HTTP_POST;

HTTP_PUT static

static const std::string HTTP_PUT;

HTTP_TRACE static

static const std::string HTTP_TRACE;

PROXY_AUTHORIZATION static

static const std::string PROXY_AUTHORIZATION;

UPGRADE static

static const std::string UPGRADE;