Poco::Net

class HTTPResponse

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

Description

This class encapsulates an HTTP response message.

In addition to the properties common to all HTTP messages, a HTTP response has status code and a reason phrase.

Inheritance

Direct Base Classes: HTTPMessage

All Base Classes: HTTPMessage, MessageHeader, NameValueCollection

Known Derived Classes: HTTPServerResponse, HTTPServerResponseImpl

Member Summary

Member Functions: addCookie, getCookies, getDate, getReason, getReasonForStatus, getStatus, operator =, read, setDate, setReason, setStatus, setStatusAndReason, 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

Enumerations

HTTPStatus

HTTP_CONTINUE = 100

HTTP_SWITCHING_PROTOCOLS = 101

HTTP_PROCESSING = 102

HTTP_OK = 200

HTTP_CREATED = 201

HTTP_ACCEPTED = 202

HTTP_NONAUTHORITATIVE = 203

HTTP_NO_CONTENT = 204

HTTP_RESET_CONTENT = 205

HTTP_PARTIAL_CONTENT = 206

HTTP_MULTI_STATUS = 207

HTTP_ALREADY_REPORTED = 208

HTTP_IM_USED = 226

HTTP_MULTIPLE_CHOICES = 300

HTTP_MOVED_PERMANENTLY = 301

HTTP_FOUND = 302

HTTP_SEE_OTHER = 303

HTTP_NOT_MODIFIED = 304

HTTP_USE_PROXY = 305

HTTP_USEPROXY = 305

HTTP_TEMPORARY_REDIRECT = 307

HTTP_PERMANENT_REDIRECT = 308

HTTP_BAD_REQUEST = 400

HTTP_UNAUTHORIZED = 401

HTTP_PAYMENT_REQUIRED = 402

HTTP_FORBIDDEN = 403

HTTP_NOT_FOUND = 404

HTTP_METHOD_NOT_ALLOWED = 405

HTTP_NOT_ACCEPTABLE = 406

HTTP_PROXY_AUTHENTICATION_REQUIRED = 407

HTTP_REQUEST_TIMEOUT = 408

HTTP_CONFLICT = 409

HTTP_GONE = 410

HTTP_LENGTH_REQUIRED = 411

HTTP_PRECONDITION_FAILED = 412

HTTP_REQUEST_ENTITY_TOO_LARGE = 413

HTTP_REQUESTENTITYTOOLARGE = 413

HTTP_REQUEST_URI_TOO_LONG = 414

HTTP_REQUESTURITOOLONG = 414

HTTP_UNSUPPORTED_MEDIA_TYPE = 415

HTTP_UNSUPPORTEDMEDIATYPE = 415

HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416

HTTP_EXPECTATION_FAILED = 417

HTTP_IM_A_TEAPOT = 418

HTTP_ENCHANCE_YOUR_CALM = 420

HTTP_MISDIRECTED_REQUEST = 421

HTTP_UNPROCESSABLE_ENTITY = 422

HTTP_LOCKED = 423

HTTP_FAILED_DEPENDENCY = 424

HTTP_TOO_EARLY = 425

HTTP_UPGRADE_REQUIRED = 426

HTTP_PRECONDITION_REQUIRED = 428

HTTP_TOO_MANY_REQUESTS = 429

HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431

HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451

HTTP_INTERNAL_SERVER_ERROR = 500

HTTP_NOT_IMPLEMENTED = 501

HTTP_BAD_GATEWAY = 502

HTTP_SERVICE_UNAVAILABLE = 503

HTTP_GATEWAY_TIMEOUT = 504

HTTP_VERSION_NOT_SUPPORTED = 505

HTTP_VARIANT_ALSO_NEGOTIATES = 506

HTTP_INSUFFICIENT_STORAGE = 507

HTTP_LOOP_DETECTED = 508

HTTP_NOT_EXTENDED = 510

HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511

Constructors

HTTPResponse

HTTPResponse();

Creates the HTTPResponse with OK status.

HTTPResponse

explicit HTTPResponse(
    HTTPStatus status
);

Creates the HTTPResponse with the given status and an appropriate reason phrase.

HTTPResponse

HTTPResponse(
    const HTTPResponse & other
);

Creates the HTTPResponse by copying another one.

HTTPResponse

HTTPResponse(
    HTTPStatus status,
    const std::string & reason
);

Creates the HTTPResponse with the given status and reason phrase.

HTTPResponse

HTTPResponse(
    const std::string & version,
    HTTPStatus status
);

Creates the HTTPResponse with the given version, status and an appropriate reason phrase.

HTTPResponse

HTTPResponse(
    const std::string & version,
    HTTPStatus status,
    const std::string & reason
);

Creates the HTTPResponse with the given version, status and reason phrase.

Destructor

~HTTPResponse virtual

~HTTPResponse() override;

Destroys the HTTPResponse.

Member Functions

addCookie

void addCookie(
    const HTTPCookie & cookie
);

Adds the cookie to the response by adding a Set-Cookie header.

getCookies

void getCookies(
    std::vector < HTTPCookie > & cookies
) const;

Returns a vector with all the cookies set in the response header.

May throw an exception in case of a malformed Set-Cookie header.

getDate

Poco::Timestamp getDate() const;

Returns the value of the Date header.

getReason inline

const std::string & getReason() const;

Returns the HTTP reason phrase.

getReasonForStatus static

static const std::string & getReasonForStatus(
    HTTPStatus status
);

Returns an appropriate reason phrase for the given status code.

getStatus inline

HTTPStatus getStatus() const;

Returns the HTTP status code.

operator =

HTTPResponse & operator = (
    const HTTPResponse & other
);

Assignment operator.

read virtual

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

Reads the HTTP response from the given input stream.

100 Continue responses are ignored.

setDate

void setDate(
    const Poco::Timestamp & dateTime
);

Sets the Date header to the given date/time value.

setReason

void setReason(
    const std::string & reason
);

Sets the HTTP reason phrase.

setStatus

void setStatus(
    HTTPStatus status
);

Sets the HTTP status code.

Does not change the reason phrase.

setStatus

void setStatus(
    const std::string & status
);

Sets the HTTP status code.

The string must contain a valid HTTP numerical status code.

setStatusAndReason

void setStatusAndReason(
    HTTPStatus status,
    const std::string & reason
);

Sets the HTTP status code and reason phrase.

setStatusAndReason

void setStatusAndReason(
    HTTPStatus status
);

Sets the HTTP status code and reason phrase.

The reason phrase is set according to the status code.

write virtual

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

Writes the HTTP response to the given output stream.

Variables

DATE static

static const std::string DATE;

HTTP_REASON_ACCEPTED static

static const std::string HTTP_REASON_ACCEPTED;

HTTP_REASON_ALREADY_REPORTED static

static const std::string HTTP_REASON_ALREADY_REPORTED;

HTTP_REASON_BAD_GATEWAY static

static const std::string HTTP_REASON_BAD_GATEWAY;

HTTP_REASON_BAD_REQUEST static

static const std::string HTTP_REASON_BAD_REQUEST;

HTTP_REASON_CONFLICT static

static const std::string HTTP_REASON_CONFLICT;

HTTP_REASON_CONTINUE static

static const std::string HTTP_REASON_CONTINUE;

HTTP_REASON_CREATED static

static const std::string HTTP_REASON_CREATED;

HTTP_REASON_ENCHANCE_YOUR_CALM static

static const std::string HTTP_REASON_ENCHANCE_YOUR_CALM;

HTTP_REASON_EXPECTATION_FAILED static

static const std::string HTTP_REASON_EXPECTATION_FAILED;

HTTP_REASON_FAILED_DEPENDENCY static

static const std::string HTTP_REASON_FAILED_DEPENDENCY;

HTTP_REASON_FORBIDDEN static

static const std::string HTTP_REASON_FORBIDDEN;

HTTP_REASON_FOUND static

static const std::string HTTP_REASON_FOUND;

HTTP_REASON_GATEWAY_TIMEOUT static

static const std::string HTTP_REASON_GATEWAY_TIMEOUT;

HTTP_REASON_GONE static

static const std::string HTTP_REASON_GONE;

HTTP_REASON_IM_A_TEAPOT static

static const std::string HTTP_REASON_IM_A_TEAPOT;

HTTP_REASON_IM_USED static

static const std::string HTTP_REASON_IM_USED;

HTTP_REASON_INSUFFICIENT_STORAGE static

static const std::string HTTP_REASON_INSUFFICIENT_STORAGE;

HTTP_REASON_INTERNAL_SERVER_ERROR static

static const std::string HTTP_REASON_INTERNAL_SERVER_ERROR;

HTTP_REASON_LENGTH_REQUIRED static

static const std::string HTTP_REASON_LENGTH_REQUIRED;

HTTP_REASON_LOCKED static

static const std::string HTTP_REASON_LOCKED;

HTTP_REASON_LOOP_DETECTED static

static const std::string HTTP_REASON_LOOP_DETECTED;

HTTP_REASON_METHOD_NOT_ALLOWED static

static const std::string HTTP_REASON_METHOD_NOT_ALLOWED;

HTTP_REASON_MISDIRECTED_REQUEST static

static const std::string HTTP_REASON_MISDIRECTED_REQUEST;

HTTP_REASON_MOVED_PERMANENTLY static

static const std::string HTTP_REASON_MOVED_PERMANENTLY;

HTTP_REASON_MULTIPLE_CHOICES static

static const std::string HTTP_REASON_MULTIPLE_CHOICES;

HTTP_REASON_MULTI_STATUS static

static const std::string HTTP_REASON_MULTI_STATUS;

HTTP_REASON_NETWORK_AUTHENTICATION_REQUIRED static

static const std::string HTTP_REASON_NETWORK_AUTHENTICATION_REQUIRED;

HTTP_REASON_NONAUTHORITATIVE static

static const std::string HTTP_REASON_NONAUTHORITATIVE;

HTTP_REASON_NOT_ACCEPTABLE static

static const std::string HTTP_REASON_NOT_ACCEPTABLE;

HTTP_REASON_NOT_EXTENDED static

static const std::string HTTP_REASON_NOT_EXTENDED;

HTTP_REASON_NOT_FOUND static

static const std::string HTTP_REASON_NOT_FOUND;

HTTP_REASON_NOT_IMPLEMENTED static

static const std::string HTTP_REASON_NOT_IMPLEMENTED;

HTTP_REASON_NOT_MODIFIED static

static const std::string HTTP_REASON_NOT_MODIFIED;

HTTP_REASON_NO_CONTENT static

static const std::string HTTP_REASON_NO_CONTENT;

HTTP_REASON_OK static

static const std::string HTTP_REASON_OK;

HTTP_REASON_PARTIAL_CONTENT static

static const std::string HTTP_REASON_PARTIAL_CONTENT;

HTTP_REASON_PAYMENT_REQUIRED static

static const std::string HTTP_REASON_PAYMENT_REQUIRED;

HTTP_REASON_PERMANENT_REDIRECT static

static const std::string HTTP_REASON_PERMANENT_REDIRECT;

HTTP_REASON_PRECONDITION_FAILED static

static const std::string HTTP_REASON_PRECONDITION_FAILED;

HTTP_REASON_PRECONDITION_REQUIRED static

static const std::string HTTP_REASON_PRECONDITION_REQUIRED;

HTTP_REASON_PROCESSING static

static const std::string HTTP_REASON_PROCESSING;

HTTP_REASON_PROXY_AUTHENTICATION_REQUIRED static

static const std::string HTTP_REASON_PROXY_AUTHENTICATION_REQUIRED;

HTTP_REASON_REQUESTED_RANGE_NOT_SATISFIABLE static

static const std::string HTTP_REASON_REQUESTED_RANGE_NOT_SATISFIABLE;

HTTP_REASON_REQUEST_ENTITY_TOO_LARGE static

static const std::string HTTP_REASON_REQUEST_ENTITY_TOO_LARGE;

HTTP_REASON_REQUEST_HEADER_FIELDS_TOO_LARGE static

static const std::string HTTP_REASON_REQUEST_HEADER_FIELDS_TOO_LARGE;

HTTP_REASON_REQUEST_TIMEOUT static

static const std::string HTTP_REASON_REQUEST_TIMEOUT;

HTTP_REASON_REQUEST_URI_TOO_LONG static

static const std::string HTTP_REASON_REQUEST_URI_TOO_LONG;

HTTP_REASON_RESET_CONTENT static

static const std::string HTTP_REASON_RESET_CONTENT;

HTTP_REASON_SEE_OTHER static

static const std::string HTTP_REASON_SEE_OTHER;

HTTP_REASON_SERVICE_UNAVAILABLE static

static const std::string HTTP_REASON_SERVICE_UNAVAILABLE;

HTTP_REASON_SWITCHING_PROTOCOLS static

static const std::string HTTP_REASON_SWITCHING_PROTOCOLS;

HTTP_REASON_TEMPORARY_REDIRECT static

static const std::string HTTP_REASON_TEMPORARY_REDIRECT;

HTTP_REASON_TOO_EARLY static

static const std::string HTTP_REASON_TOO_EARLY;

HTTP_REASON_TOO_MANY_REQUESTS static

static const std::string HTTP_REASON_TOO_MANY_REQUESTS;

HTTP_REASON_UNAUTHORIZED static

static const std::string HTTP_REASON_UNAUTHORIZED;

HTTP_REASON_UNAVAILABLE_FOR_LEGAL_REASONS static

static const std::string HTTP_REASON_UNAVAILABLE_FOR_LEGAL_REASONS;

HTTP_REASON_UNKNOWN static

static const std::string HTTP_REASON_UNKNOWN;

HTTP_REASON_UNPROCESSABLE_ENTITY static

static const std::string HTTP_REASON_UNPROCESSABLE_ENTITY;

HTTP_REASON_UNSUPPORTED_MEDIA_TYPE static

static const std::string HTTP_REASON_UNSUPPORTED_MEDIA_TYPE;

HTTP_REASON_UPGRADE_REQUIRED static

static const std::string HTTP_REASON_UPGRADE_REQUIRED;

HTTP_REASON_USE_PROXY static

static const std::string HTTP_REASON_USE_PROXY;

HTTP_REASON_VARIANT_ALSO_NEGOTIATES static

static const std::string HTTP_REASON_VARIANT_ALSO_NEGOTIATES;

HTTP_REASON_VERSION_NOT_SUPPORTED static

static const std::string HTTP_REASON_VERSION_NOT_SUPPORTED;

SET_COOKIE static

static const std::string SET_COOKIE;