Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Poco::Net::HTTPRequest Class Reference

#include <HTTPRequest.h>

+ Inheritance diagram for Poco::Net::HTTPRequest:
+ Collaboration diagram for Poco::Net::HTTPRequest:

Public Member Functions

 HTTPRequest ()
 
 HTTPRequest (const std::string &version)
 Creates a GET / HTTP/1.0 HTTP request.
 
 HTTPRequest (const std::string &method, const std::string &uri)
 
 HTTPRequest (const std::string &method, const std::string &uri, const std::string &version)
 Creates a HTTP/1.0 request with the given method and URI.
 
 HTTPRequest (const HTTPRequest &other)
 Creates a HTTP request with the given method, URI and version.
 
virtual ~HTTPRequest ()
 Creates a HTTP request by copying another one.
 
HTTPRequestoperator= (const HTTPRequest &)
 Destroys the HTTPRequest.
 
void setMethod (const std::string &method)
 Assignment operator.
 
const std::string & getMethod () const
 Sets the method.
 
void setURI (const std::string &uri)
 Returns the method.
 
const std::string & getURI () const
 Sets the request URI.
 
void setHost (const std::string &host)
 Returns the request URI.
 
void setHost (const std::string &host, Poco::UInt16 port)
 Sets the value of the Host header field.
 
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)
 
void removeCredentials ()
 
bool getExpectContinue () const
 Removes any credentials from the request.
 
void setExpectContinue (bool expectContinue)
 
bool hasProxyCredentials () const
 
void getProxyCredentials (std::string &scheme, std::string &authInfo) const
 
void setProxyCredentials (const std::string &scheme, const std::string &authInfo)
 
void removeProxyCredentials ()
 
void write (std::ostream &ostr) const
 Removes any proxy credentials from the request.
 
void read (std::istream &istr)
 
- Public Member Functions inherited from Poco::Net::HTTPMessage
void setVersion (const std::string &version)
 
const std::string & getVersion () const
 Sets the HTTP version for this message.
 
void setContentLength (std::streamsize length)
 Returns the HTTP version for this message.
 
std::streamsize getContentLength () const
 
bool hasContentLength () const
 
void setTransferEncoding (const std::string &transferEncoding)
 Returns true iff a Content-Length header is present.
 
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
 Sets the content type for this message.
 
void setKeepAlive (bool keepAlive)
 
bool getKeepAlive () const
 
- Public Member Functions inherited from Poco::Net::MessageHeader
 MessageHeader ()
 
 MessageHeader (const MessageHeader &messageHeader)
 Creates the MessageHeader.
 
virtual ~MessageHeader ()
 
MessageHeaderoperator= (const MessageHeader &messageHeader)
 Destroys the MessageHeader.
 
int getFieldLimit () const
 
void setFieldLimit (int limit)
 
bool hasToken (const std::string &fieldName, const std::string &token) const
 
- Public Member Functions inherited from Poco::Net::NameValueCollection
 NameValueCollection ()
 
 NameValueCollection (const NameValueCollection &nvc)
 Creates an empty NameValueCollection.
 
 NameValueCollection (NameValueCollection &&nvc) noexcept
 Creates a NameValueCollection by copying another one.
 
virtual ~NameValueCollection ()
 Creates a NameValueCollection by moving another one.
 
NameValueCollectionoperator= (const NameValueCollection &nvc)
 Destroys the NameValueCollection.
 
NameValueCollectionoperator= (NameValueCollection &&nvc) noexcept
 Assigns the name-value pairs of another NameValueCollection to this one.
 
void swap (NameValueCollection &nvc)
 Moves the name-value pairs of another NameValueCollection to this one.
 
const std::string & operator[] (const std::string &name) const
 Swaps the NameValueCollection with another one.
 
void set (const std::string &name, const std::string &value)
 
void add (const std::string &name, const std::string &value)
 Sets the value of the (first) name-value pair with the given name.
 
const std::string & get (const std::string &name) const
 Adds a new name-value pair with the given name and value.
 
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
 Returns true iff the header does not have any content.
 
void erase (const std::string &name)
 
void clear ()
 Removes all name-value pairs with the given name.
 

Static Public Attributes

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
 
static const std::string EXPECT
 
- Static Public Attributes inherited from Poco::Net::HTTPMessage
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 PROXY_CONNECTION
 
static const std::string CONNECTION_KEEP_ALIVE
 
static const std::string CONNECTION_CLOSE
 
static const std::string EMPTY
 

Protected Member Functions

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)
 
- Protected Member Functions inherited from Poco::Net::HTTPMessage
 HTTPMessage ()
 
 HTTPMessage (const std::string &version)
 Creates the HTTPMessage with version HTTP/1.0.
 
 HTTPMessage (const HTTPMessage &other)
 
HTTPMessageoperator= (const HTTPMessage &other)
 Copy constructor.
 
virtual ~HTTPMessage ()
 Assignment operator.
 

Private Types

enum  Limits { MAX_METHOD_LENGTH = 32 , MAX_URI_LENGTH = 16384 , MAX_VERSION_LENGTH = 8 }
 

Private Attributes

std::string _method
 
std::string _uri
 

Additional Inherited Members

- Public Types inherited from Poco::Net::NameValueCollection
using HeaderMap = Poco::ListMap<std::string, std::string>
 
using Iterator = HeaderMap::Iterator
 
using ConstIterator = HeaderMap::ConstIterator
 
- Static Public Member Functions inherited from Poco::Net::MessageHeader
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)
 
static void decodeRFC2047 (const std::string &ins, std::string &outs, const std::string &charset="UTF-8")
 
static std::string decodeWord (const std::string &text, const std::string &charset="UTF-8")
 

Detailed 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.

Definition at line 29 of file HTTPRequest.h.

Member Enumeration Documentation

◆ Limits

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

Enumerator
MAX_METHOD_LENGTH 
MAX_URI_LENGTH 
MAX_VERSION_LENGTH 

Definition at line 179 of file HTTPRequest.h.

Constructor & Destructor Documentation

◆ HTTPRequest() [1/5]

Poco::Net::HTTPRequest::HTTPRequest ( )

◆ HTTPRequest() [2/5]

Poco::Net::HTTPRequest::HTTPRequest ( const std::string & version)
explicit

Creates a GET / HTTP/1.0 HTTP request.

◆ HTTPRequest() [3/5]

Poco::Net::HTTPRequest::HTTPRequest ( const std::string & method,
const std::string & uri )

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

◆ HTTPRequest() [4/5]

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

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

+ Here is the caller graph for this function:

◆ HTTPRequest() [5/5]

Poco::Net::HTTPRequest::HTTPRequest ( const HTTPRequest & other)

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

◆ ~HTTPRequest()

virtual Poco::Net::HTTPRequest::~HTTPRequest ( )
virtual

Creates a HTTP request by copying another one.

Member Function Documentation

◆ getCookies()

void Poco::Net::HTTPRequest::getCookies ( NameValueCollection & cookies) const

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

◆ getCredentials() [1/2]

void Poco::Net::HTTPRequest::getCredentials ( const std::string & header,
std::string & scheme,
std::string & authInfo ) const
protected

◆ getCredentials() [2/2]

void Poco::Net::HTTPRequest::getCredentials ( std::string & scheme,
std::string & authInfo ) const

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

◆ getExpectContinue()

bool Poco::Net::HTTPRequest::getExpectContinue ( ) const

Removes any credentials from the request.

◆ getHost()

const std::string & Poco::Net::HTTPRequest::getHost ( ) const

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.

◆ getMethod()

const std::string & Poco::Net::HTTPRequest::getMethod ( ) const
inline

Sets the method.

Definition at line 194 of file HTTPRequest.h.

◆ getProxyCredentials()

void Poco::Net::HTTPRequest::getProxyCredentials ( std::string & scheme,
std::string & authInfo ) const

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

◆ getURI()

const std::string & Poco::Net::HTTPRequest::getURI ( ) const
inline

Sets the request URI.

Definition at line 200 of file HTTPRequest.h.

◆ hasCredentials()

bool Poco::Net::HTTPRequest::hasCredentials ( ) const

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

◆ hasProxyCredentials()

bool Poco::Net::HTTPRequest::hasProxyCredentials ( ) const

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

◆ operator=()

HTTPRequest & Poco::Net::HTTPRequest::operator= ( const HTTPRequest & )

Destroys the HTTPRequest.

◆ read()

void Poco::Net::HTTPRequest::read ( std::istream & istr)
virtual

Writes the HTTP request to the given output stream.

Reimplemented from Poco::Net::MessageHeader.

◆ removeCredentials()

void Poco::Net::HTTPRequest::removeCredentials ( )

Sets the authentication scheme and information for this request.

◆ removeProxyCredentials()

void Poco::Net::HTTPRequest::removeProxyCredentials ( )

Sets the proxy authentication scheme and information for this request.

◆ setCookies()

void Poco::Net::HTTPRequest::setCookies ( const NameValueCollection & cookies)

Returns the value of the Host header field.

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

◆ setCredentials() [1/2]

void Poco::Net::HTTPRequest::setCredentials ( const std::string & header,
const std::string & scheme,
const std::string & authInfo )
protected

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() [2/2]

void Poco::Net::HTTPRequest::setCredentials ( const std::string & scheme,
const std::string & authInfo )

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

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

◆ setExpectContinue()

void Poco::Net::HTTPRequest::setExpectContinue ( bool expectContinue)

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

◆ setHost() [1/2]

void Poco::Net::HTTPRequest::setHost ( const std::string & host)

Returns the request URI.

◆ setHost() [2/2]

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

Sets the value of the Host header field.

◆ setMethod()

void Poco::Net::HTTPRequest::setMethod ( const std::string & method)

Assignment operator.

◆ setProxyCredentials()

void Poco::Net::HTTPRequest::setProxyCredentials ( const std::string & scheme,
const std::string & authInfo )

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.

◆ setURI()

void Poco::Net::HTTPRequest::setURI ( const std::string & uri)

Returns the method.

◆ write()

void Poco::Net::HTTPRequest::write ( std::ostream & ostr) const
virtual

Removes any proxy credentials from the request.

Reimplemented from Poco::Net::MessageHeader.

Member Data Documentation

◆ _method

std::string Poco::Net::HTTPRequest::_method
private

Definition at line 186 of file HTTPRequest.h.

◆ _uri

std::string Poco::Net::HTTPRequest::_uri
private

Definition at line 187 of file HTTPRequest.h.

◆ AUTHORIZATION

const std::string Poco::Net::HTTPRequest::AUTHORIZATION
static

Definition at line 161 of file HTTPRequest.h.

◆ COOKIE

const std::string Poco::Net::HTTPRequest::COOKIE
static

Definition at line 160 of file HTTPRequest.h.

◆ EXPECT

const std::string Poco::Net::HTTPRequest::EXPECT
static

Definition at line 164 of file HTTPRequest.h.

◆ HOST

const std::string Poco::Net::HTTPRequest::HOST
static

Definition at line 159 of file HTTPRequest.h.

◆ HTTP_CONNECT

const std::string Poco::Net::HTTPRequest::HTTP_CONNECT
static

Definition at line 156 of file HTTPRequest.h.

◆ HTTP_DELETE

const std::string Poco::Net::HTTPRequest::HTTP_DELETE
static

Definition at line 154 of file HTTPRequest.h.

◆ HTTP_GET

const std::string Poco::Net::HTTPRequest::HTTP_GET
static

Reads the HTTP request from the given input stream.

Definition at line 149 of file HTTPRequest.h.

◆ HTTP_HEAD

const std::string Poco::Net::HTTPRequest::HTTP_HEAD
static

Definition at line 150 of file HTTPRequest.h.

◆ HTTP_OPTIONS

const std::string Poco::Net::HTTPRequest::HTTP_OPTIONS
static

Definition at line 153 of file HTTPRequest.h.

◆ HTTP_PATCH

const std::string Poco::Net::HTTPRequest::HTTP_PATCH
static

Definition at line 157 of file HTTPRequest.h.

◆ HTTP_POST

const std::string Poco::Net::HTTPRequest::HTTP_POST
static

Definition at line 152 of file HTTPRequest.h.

◆ HTTP_PUT

const std::string Poco::Net::HTTPRequest::HTTP_PUT
static

Definition at line 151 of file HTTPRequest.h.

◆ HTTP_TRACE

const std::string Poco::Net::HTTPRequest::HTTP_TRACE
static

Definition at line 155 of file HTTPRequest.h.

◆ PROXY_AUTHORIZATION

const std::string Poco::Net::HTTPRequest::PROXY_AUTHORIZATION
static

Definition at line 162 of file HTTPRequest.h.

◆ UPGRADE

const std::string Poco::Net::HTTPRequest::UPGRADE
static

Definition at line 163 of file HTTPRequest.h.


The documentation for this class was generated from the following file: