Library: Net
Package: HTTP
Header: Poco/Net/HTTPRequest.h
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.
Direct Base Classes: HTTPMessage
All Base Classes: HTTPMessage, MessageHeader, NameValueCollection
Known Derived Classes: HTTPServerRequest, HTTPServerRequestImpl
Member Functions: getCookies, getCredentials, getHost, getMethod, getURI, hasCredentials, read, setCookies, setCredentials, setHost, setMethod, setURI, write
Inherited Functions: add, begin, clear, empty, end, erase, find, get, getChunkedTransferEncoding, getContentLength, getContentType, getKeepAlive, getTransferEncoding, getVersion, has, operator =, operator [], quote, read, set, setChunkedTransferEncoding, setContentLength, setContentType, setKeepAlive, setTransferEncoding, setVersion, size, splitElements, splitParameters, swap, write
HTTPRequest();
Creates a GET / HTTP/1.0 HTTP request.
HTTPRequest(
const std::string & version
);
Creates a GET / HTTP/1.x request with the given version (HTTP/1.0 or HTTP/1.1).
HTTPRequest(
const std::string & method,
const std::string & uri
);
Creates a HTTP/1.0 request with the given method and URI.
HTTPRequest(
const std::string & method,
const std::string & uri,
const std::string & version
);
Creates a HTTP request with the given method, URI and version.
virtual ~HTTPRequest();
Destroys the HTTPRequest.
void getCookies(
NameValueCollection & cookies
) const;
Fills cookies with the cookies extracted from the Cookie headers in the request.
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.
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.
const std::string & getMethod() const;
Returns the method.
const std::string & getURI() const;
Returns the request URI.
bool hasCredentials() const;
Returns true if and only if the request contains authentication information in the form of an Authorization header.
void read(
std::istream & istr
);
Reads the HTTP request from the given input stream.
See also: Poco::Net::MessageHeader::read()
void setCookies(
const NameValueCollection & cookies
);
Adds a Cookie header with the names and values from cookies.
void setCredentials(
const std::string & scheme,
const std::string & authInfo
);
Sets the authentication scheme and information for this request.
void setHost(
const std::string & host
);
Sets the value of the Host header field.
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.
void setMethod(
const std::string & method
);
Sets the method.
void setURI(
const std::string & uri
);
Sets the request URI.
void write(
std::ostream & ostr
) const;
Writes the HTTP request to the given output stream.
See also: Poco::Net::MessageHeader::write()
static const std::string AUTHORIZATION;
static const std::string COOKIE;
static const std::string HOST;
static const std::string HTTP_CONNECT;
static const std::string HTTP_DELETE;
static const std::string HTTP_GET;
static const std::string HTTP_HEAD;
static const std::string HTTP_OPTIONS;
static const std::string HTTP_POST;
static const std::string HTTP_PUT;
static const std::string HTTP_TRACE;