mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 19:51:58 +01:00
backport changes from 1.4.3 branch
This commit is contained in:
@@ -82,11 +82,14 @@ public:
|
||||
DialogSocket(const Socket& socket);
|
||||
/// Creates the DialogSocket with the SocketImpl
|
||||
/// from another socket. The SocketImpl must be
|
||||
/// a StreamSocketImpl, otherwise an InvalidArgumentException
|
||||
/// will be thrown.
|
||||
/// a StreamSocketImpl, otherwise an InvalidArgumentException
|
||||
/// will be thrown.
|
||||
|
||||
~DialogSocket();
|
||||
/// Destroys the DialogSocket.
|
||||
DialogSocket(const DialogSocket& socket);
|
||||
/// Creates the DialogSocket as copy of another dialog socket.
|
||||
|
||||
~DialogSocket();
|
||||
/// Destroys the DialogSocket.
|
||||
|
||||
DialogSocket& operator = (const Socket& socket);
|
||||
/// Assignment operator.
|
||||
|
||||
@@ -57,11 +57,18 @@ class PartSource;
|
||||
|
||||
|
||||
class Net_API HTMLForm: public NameValueCollection
|
||||
/// HTMLForm is a helper class for working with HTML forms,
|
||||
/// both on the client and on the server side.
|
||||
/// HTMLForm is a helper class for working with HTML forms,
|
||||
/// both on the client and on the server side.
|
||||
///
|
||||
/// The maximum number of form fields can be restricted
|
||||
/// by calling setFieldLimit(). This is useful to
|
||||
/// defend against certain kinds of denial-of-service
|
||||
/// attacks. The limit is only enforced when parsing
|
||||
/// form data from a stream or string, not when adding
|
||||
/// form fields programmatically. The default limit is 100.
|
||||
{
|
||||
public:
|
||||
HTMLForm();
|
||||
HTMLForm();
|
||||
/// Creates an empty HTMLForm and sets the
|
||||
/// encoding to "application/x-www-form-urlencoded".
|
||||
|
||||
@@ -133,12 +140,27 @@ public:
|
||||
|
||||
void read(std::istream& istr, PartHandler& handler);
|
||||
/// Reads the form data from the given input stream.
|
||||
///
|
||||
/// The form data read from the stream must be
|
||||
/// in the encoding specified for the form.
|
||||
|
||||
void prepareSubmit(HTTPRequest& request);
|
||||
/// Fills out the request object for submitting the form.
|
||||
///
|
||||
/// The form data read from the stream must be
|
||||
/// in the encoding specified for the form.
|
||||
///
|
||||
/// Note that read() does not clear the form before
|
||||
/// reading the new values.
|
||||
|
||||
void read(std::istream& istr);
|
||||
/// Reads the URL-encoded form data from the given input stream.
|
||||
///
|
||||
/// Note that read() does not clear the form before
|
||||
/// reading the new values.
|
||||
|
||||
void read(const std::string& queryString);
|
||||
/// Reads the form data from the given HTTP query string.
|
||||
///
|
||||
/// Note that read() does not clear the form before
|
||||
/// reading the new values.
|
||||
|
||||
void prepareSubmit(HTTPRequest& request);
|
||||
/// Fills out the request object for submitting the form.
|
||||
///
|
||||
/// If the request method is GET, the encoded form is appended to the
|
||||
/// request URI as query string. Otherwise (the method is
|
||||
@@ -161,11 +183,25 @@ public:
|
||||
/// using the specified encoding.
|
||||
|
||||
const std::string& boundary() const;
|
||||
/// Returns the MIME boundary used for writing
|
||||
/// multipart form data.
|
||||
/// Returns the MIME boundary used for writing
|
||||
/// multipart form data.
|
||||
|
||||
static const std::string ENCODING_URL; /// "application/x-www-form-urlencoded"
|
||||
static const std::string ENCODING_MULTIPART; /// "multipart/form-data"
|
||||
int getFieldLimit() const;
|
||||
/// Returns the maximum number of header fields
|
||||
/// allowed.
|
||||
///
|
||||
/// See setFieldLimit() for more information.
|
||||
|
||||
void setFieldLimit(int limit);
|
||||
/// Sets the maximum number of header fields
|
||||
/// allowed. This limit is used to defend certain
|
||||
/// kinds of denial-of-service attacks.
|
||||
/// Specify 0 for unlimited (not recommended).
|
||||
///
|
||||
/// The default limit is 100.
|
||||
|
||||
static const std::string ENCODING_URL; /// "application/x-www-form-urlencoded"
|
||||
static const std::string ENCODING_MULTIPART; /// "multipart/form-data"
|
||||
|
||||
protected:
|
||||
void readUrl(std::istream& istr);
|
||||
@@ -174,20 +210,26 @@ protected:
|
||||
void writeMultipart(std::ostream& ostr);
|
||||
|
||||
private:
|
||||
HTMLForm(const HTMLForm&);
|
||||
HTMLForm& operator = (const HTMLForm&);
|
||||
HTMLForm(const HTMLForm&);
|
||||
HTMLForm& operator = (const HTMLForm&);
|
||||
|
||||
struct Part
|
||||
{
|
||||
std::string name;
|
||||
enum Limits
|
||||
{
|
||||
DFL_FIELD_LIMIT = 100
|
||||
};
|
||||
|
||||
struct Part
|
||||
{
|
||||
std::string name;
|
||||
PartSource* pSource;
|
||||
};
|
||||
|
||||
typedef std::vector<Part> PartVec;
|
||||
|
||||
std::string _encoding;
|
||||
std::string _boundary;
|
||||
PartVec _parts;
|
||||
|
||||
typedef std::vector<Part> PartVec;
|
||||
|
||||
int _fieldLimit;
|
||||
std::string _encoding;
|
||||
std::string _boundary;
|
||||
PartVec _parts;
|
||||
};
|
||||
|
||||
|
||||
@@ -206,6 +248,12 @@ inline const std::string& HTMLForm::boundary() const
|
||||
}
|
||||
|
||||
|
||||
inline int HTMLForm::getFieldLimit() const
|
||||
{
|
||||
return _fieldLimit;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
||||
|
||||
|
||||
@@ -66,11 +66,16 @@ public:
|
||||
/// Creates a HTTPBasicCredentials object with the authentication information
|
||||
/// from the given request.
|
||||
///
|
||||
/// Throws a NotAuthenticatedException if the request does
|
||||
/// not contain basic authentication information.
|
||||
/// Throws a NotAuthenticatedException if the request does
|
||||
/// not contain basic authentication information.
|
||||
|
||||
~HTTPBasicCredentials();
|
||||
/// Destroys the HTTPBasicCredentials.
|
||||
explicit HTTPBasicCredentials(const std::string& authInfo);
|
||||
/// Creates a HTTPBasicCredentials object with the authentication information
|
||||
/// in the given string. The authentication information can be extracted
|
||||
/// from a HTTPRequest object by calling HTTPRequest::getCredentials().
|
||||
|
||||
~HTTPBasicCredentials();
|
||||
/// Destroys the HTTPBasicCredentials.
|
||||
|
||||
void setUsername(const std::string& username);
|
||||
/// Sets the username.
|
||||
@@ -87,14 +92,20 @@ public:
|
||||
void authenticate(HTTPRequest& request);
|
||||
/// Adds authentication information to the given HTTPRequest.
|
||||
|
||||
static const std::string SCHEME;
|
||||
static const std::string SCHEME;
|
||||
|
||||
protected:
|
||||
void parseAuthInfo(const std::string& authInfo);
|
||||
/// Extracts username and password from Basic authentication info
|
||||
/// by base64-decoding authInfo and splitting the resulting
|
||||
/// string at the ':' delimiter.
|
||||
|
||||
private:
|
||||
HTTPBasicCredentials(const HTTPBasicCredentials&);
|
||||
HTTPBasicCredentials& operator = (const HTTPBasicCredentials);
|
||||
|
||||
std::string _username;
|
||||
std::string _password;
|
||||
HTTPBasicCredentials(const HTTPBasicCredentials&);
|
||||
HTTPBasicCredentials& operator = (const HTTPBasicCredentials&);
|
||||
|
||||
std::string _username;
|
||||
std::string _password;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -62,23 +62,42 @@ public:
|
||||
void setVersion(const std::string& version);
|
||||
/// Sets the HTTP version for this message.
|
||||
|
||||
const std::string& getVersion() const;
|
||||
/// Returns the HTTP version for this message.
|
||||
|
||||
void setContentLength(std::streamsize length);
|
||||
const std::string& getVersion() const;
|
||||
/// Returns the HTTP version for this message.
|
||||
|
||||
void setContentLength(std::streamsize length);
|
||||
/// Sets the Content-Length header.
|
||||
///
|
||||
/// If length is UNKNOWN_CONTENT_LENGTH, removes
|
||||
/// the Content-Length header.
|
||||
|
||||
std::streamsize getContentLength() const;
|
||||
/// Returns the content length for this message,
|
||||
/// which may be UNKNOWN_CONTENT_LENGTH if
|
||||
/// no Content-Length header is present.
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
void setContentLength64(Poco::Int64 length);
|
||||
/// Sets the Content-Length header.
|
||||
///
|
||||
/// If length is UNKNOWN_CONTENT_LENGTH, removes
|
||||
/// the Content-Length header.
|
||||
|
||||
std::streamsize getContentLength() const;
|
||||
///
|
||||
/// In contrast to setContentLength(), this method takes
|
||||
/// a 64-bit integer as content length.
|
||||
|
||||
Poco::Int64 getContentLength64() const;
|
||||
/// Returns the content length for this message,
|
||||
/// which may be UNKNOWN_CONTENT_LENGTH if
|
||||
/// no Content-Length header is present.
|
||||
///
|
||||
/// In contrast to getContentLength(), this method
|
||||
/// always returns a 64-bit integer for content length.
|
||||
#endif // defined(POCO_HAVE_INT64)
|
||||
|
||||
void setTransferEncoding(const std::string& transferEncoding);
|
||||
/// Sets the transfer encoding for this message.
|
||||
///
|
||||
void setTransferEncoding(const std::string& transferEncoding);
|
||||
/// Sets the transfer encoding for this message.
|
||||
///
|
||||
/// The value should be either IDENTITY_TRANSFER_CODING
|
||||
/// or CHUNKED_TRANSFER_CODING.
|
||||
|
||||
|
||||
@@ -62,15 +62,19 @@ public:
|
||||
HostEntry();
|
||||
/// Creates an empty HostEntry.
|
||||
|
||||
HostEntry(struct hostent* entry);
|
||||
/// Creates the HostEntry from the data in a hostent structure.
|
||||
HostEntry(struct hostent* entry);
|
||||
/// Creates the HostEntry from the data in a hostent structure.
|
||||
|
||||
#if defined(_WIN32) && defined(POCO_HAVE_IPv6)
|
||||
HostEntry(struct addrinfo* info);
|
||||
/// Creates the HostEntry from the data in a Windows addrinfo structure.
|
||||
#if defined(POCO_HAVE_IPv6) || defined(POCO_HAVE_ADDRINFO)
|
||||
HostEntry(struct addrinfo* info);
|
||||
/// Creates the HostEntry from the data in an addrinfo structure.
|
||||
#endif
|
||||
|
||||
HostEntry(const HostEntry& entry);
|
||||
#if defined(POCO_VXWORKS)
|
||||
HostEntry(const std::string& name, const IPAddress& addr);
|
||||
#endif
|
||||
|
||||
HostEntry(const HostEntry& entry);
|
||||
/// Creates the HostEntry by copying another one.
|
||||
|
||||
HostEntry& operator = (const HostEntry& entry);
|
||||
|
||||
@@ -59,12 +59,19 @@ class Net_API MessageHeader: public NameValueCollection
|
||||
///
|
||||
/// There can be more than one name-value pair with the
|
||||
/// same name.
|
||||
///
|
||||
/// MessageHeader supports writing and reading the
|
||||
/// header data in RFC 2822 format.
|
||||
///
|
||||
/// MessageHeader supports writing and reading the
|
||||
/// header data in RFC 2822 format.
|
||||
///
|
||||
/// The maximum number of fields can be restricted
|
||||
/// by calling setFieldLimit(). This is useful to
|
||||
/// defend against certain kinds of denial-of-service
|
||||
/// attacks. The limit is only enforced when parsing
|
||||
/// header fields from a stream, not when programmatically
|
||||
/// adding them. The default limit is 100.
|
||||
{
|
||||
public:
|
||||
MessageHeader();
|
||||
MessageHeader();
|
||||
/// Creates the MessageHeader.
|
||||
|
||||
MessageHeader(const MessageHeader& messageHeader);
|
||||
@@ -99,12 +106,26 @@ public:
|
||||
/// Some basic sanity checking of the input stream is
|
||||
/// performed.
|
||||
///
|
||||
/// Throws a MessageException if the input stream is
|
||||
/// malformed.
|
||||
|
||||
static void splitElements(const std::string& s, std::vector<std::string>& elements, bool ignoreEmpty = true);
|
||||
/// Splits the given string into separate elements. Elements are expected
|
||||
/// to be separated by commas.
|
||||
/// Throws a MessageException if the input stream is
|
||||
/// malformed.
|
||||
|
||||
int getFieldLimit() const;
|
||||
/// Returns the maximum number of header fields
|
||||
/// allowed.
|
||||
///
|
||||
/// See setFieldLimit() for more information.
|
||||
|
||||
void setFieldLimit(int limit);
|
||||
/// Sets the maximum number of header fields
|
||||
/// allowed. This limit is used to defend certain
|
||||
/// kinds of denial-of-service attacks.
|
||||
/// Specify 0 for unlimited (not recommended).
|
||||
///
|
||||
/// The default limit is 100.
|
||||
|
||||
static void splitElements(const std::string& s, std::vector<std::string>& elements, bool ignoreEmpty = true);
|
||||
/// Splits the given string into separate elements. Elements are expected
|
||||
/// to be separated by commas.
|
||||
///
|
||||
/// For example, the string
|
||||
/// text/plain; q=0.5, text/html, text/x-dvi; q=0.8
|
||||
@@ -136,18 +157,21 @@ public:
|
||||
///
|
||||
/// Enclosing quotes of parameter values are removed.
|
||||
|
||||
static void quote(const std::string& value, std::string& result, bool allowSpace = false);
|
||||
/// Checks if the value must be quoted. If so, the value is
|
||||
/// appended to result, enclosed in double-quotes.
|
||||
/// Otherwise, the value is appended to result as-is.
|
||||
|
||||
static void quote(const std::string& value, std::string& result, bool allowSpace = false);
|
||||
/// Checks if the value must be quoted. If so, the value is
|
||||
/// appended to result, enclosed in double-quotes.
|
||||
/// Otherwise, the value is appended to result as-is.
|
||||
|
||||
private:
|
||||
enum Limits
|
||||
/// Limits for basic sanity checks when reading a header
|
||||
{
|
||||
MAX_NAME_LENGTH = 256,
|
||||
MAX_VALUE_LENGTH = 4096
|
||||
};
|
||||
enum Limits
|
||||
/// Limits for basic sanity checks when reading a header
|
||||
{
|
||||
MAX_NAME_LENGTH = 256,
|
||||
MAX_VALUE_LENGTH = 4096,
|
||||
DFL_FIELD_LIMIT = 100
|
||||
};
|
||||
|
||||
int _fieldLimit;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ POCO_DECLARE_EXCEPTION(Net_API, FTPException, NetException)
|
||||
POCO_DECLARE_EXCEPTION(Net_API, SMTPException, NetException)
|
||||
POCO_DECLARE_EXCEPTION(Net_API, POP3Exception, NetException)
|
||||
POCO_DECLARE_EXCEPTION(Net_API, ICMPException, NetException)
|
||||
POCO_DECLARE_EXCEPTION(Net_API, HTMLFormException, NetException)
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
||||
@@ -236,11 +236,23 @@
|
||||
#endif
|
||||
|
||||
|
||||
#if POCO_OS != POCO_OS_VXWORKS
|
||||
#define POCO_HAVE_ADDRINFO 1
|
||||
#endif
|
||||
|
||||
|
||||
#if (POCO_OS == POCO_OS_HPUX) || (POCO_OS == POCO_OS_SOLARIS) || (POCO_OS == POCO_OS_WINDOWS_CE)
|
||||
#define POCO_BROKEN_TIMEOUTS 1
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(POCO_HAVE_ADDRINFO)
|
||||
#if !defined(AI_ADDRCONFIG)
|
||||
#define AI_ADDRCONFIG 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(POCO_HAVE_SALEN)
|
||||
#define poco_set_sa_len(pSA, len) (pSA)->sa_len = (len)
|
||||
#define poco_set_sin_len(pSA) (pSA)->sin_len = sizeof(struct sockaddr_in)
|
||||
|
||||
Reference in New Issue
Block a user