minor fixes, mostly style and documentation

This commit is contained in:
Guenter Obiltschnig 2017-02-15 09:52:58 +01:00
parent 68a0ff1515
commit 5692187d2d
27 changed files with 85 additions and 77 deletions

View File

@ -37,18 +37,17 @@ class Net_API DNS
/// An internal DNS cache is used to speed up name lookups.
{
public:
enum HintFlag
{
DNS_HINT_NONE = 0,
DNS_HINT_NONE = 0,
#ifdef POCO_HAVE_ADDRINFO
DNS_HINT_AI_PASSIVE = AI_PASSIVE, /// Socket address will be used in bind() call
DNS_HINT_AI_CANONNAME = AI_CANONNAME, /// Return canonical name in first ai_canonname
DNS_HINT_AI_PASSIVE = AI_PASSIVE, /// Socket address will be used in bind() call
DNS_HINT_AI_CANONNAME = AI_CANONNAME, /// Return canonical name in first ai_canonname
DNS_HINT_AI_NUMERICHOST = AI_NUMERICHOST, /// Nodename must be a numeric address string
DNS_HINT_AI_NUMERICSERV = AI_NUMERICSERV, /// Servicename must be a numeric port number
DNS_HINT_AI_ALL = AI_ALL, /// Query both IP6 and IP4 with AI_V4MAPPED
DNS_HINT_AI_ADDRCONFIG = AI_ADDRCONFIG, /// Resolution only if global address configured
DNS_HINT_AI_V4MAPPED = AI_V4MAPPED /// On v6 failure, query v4 and convert to V4MAPPED format
DNS_HINT_AI_ALL = AI_ALL, /// Query both IP6 and IP4 with AI_V4MAPPED
DNS_HINT_AI_ADDRCONFIG = AI_ADDRCONFIG, /// Resolution only if global address configured
DNS_HINT_AI_V4MAPPED = AI_V4MAPPED /// On v6 failure, query v4 and convert to V4MAPPED format
#endif
};

View File

@ -121,7 +121,7 @@ public:
protected:
DatagramSocket(SocketImpl* pImpl);
/// Creates the Socket and attaches the given SocketImpl.
/// The socket takes owership of the SocketImpl.
/// The socket takes ownership of the SocketImpl.
///
/// The SocketImpl must be a StreamSocketImpl, otherwise
/// an InvalidArgumentException will be thrown.

View File

@ -134,7 +134,7 @@ public:
void setFileType(FileType type);
/// Sets the file type for transferring files.
///
/// Sends a TYPE command with a corresponsing argument to the
/// Sends a TYPE command with a corresponding argument to the
/// server.
///
/// Throws a FTPException in case of a FTP-specific error, or a
@ -160,7 +160,7 @@ public:
void cdup();
/// Moves one directory up from the current working directory
/// on teh server.
/// on the server.
///
/// Sends a CDUP command to the server.
///
@ -227,7 +227,7 @@ public:
std::ostream& beginUpload(const std::string& path);
/// Starts uploading the file with the given name.
/// After all data has been written to the returned stream,
/// endUpload() must be called to finish the download.
/// endUpload() must be called to finish the upload.
///
/// A stream for reading the file's content is returned.
/// The stream is valid until endUpload() is called.
@ -258,7 +258,7 @@ public:
/// The stream is valid until endList() is called.
///
/// Optionally, a path to a directory or file can be specified.
/// According to the FTP prototol, if a path to a filename is
/// According to the FTP protocol, if a path to a filename is
/// given, only information for the specific file is returned.
/// If a path to a directory is given, a listing of that directory
/// is returned. If no path is given, a listing of the current

View File

@ -45,7 +45,7 @@ class Net_API HTTPClientSession: public HTTPSession
/// specify the server's host name and port number.
///
/// Then create a HTTPRequest object, fill it accordingly,
/// and pass it as argument to the sendRequst() method.
/// and pass it as argument to the sendRequest() method.
///
/// sendRequest() will return an output stream that can
/// be used to send the request body, if there is any.

View File

@ -49,9 +49,13 @@ public:
/// Destroys the HTTPRequestHandlerFactory.
virtual HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request) = 0;
/// Must be overridden by sublasses.
/// Must be overridden by subclasses.
///
/// Creates a new request handler for the given HTTP request.
///
/// The method should inspect the given HTTPServerRequest object (e.g., method
/// and URI) and create an appropriate HTTPRequestHandler object to handle the
/// request.
protected:
Poco::BasicEvent<const bool> serverStopped;

View File

@ -88,7 +88,7 @@ public:
/// Returns the connection timeout for HTTP connections.
void setMaxKeepAliveRequests(int maxKeepAliveRequests);
/// Specifies the maximun number of requests allowed
/// Specifies the maximum number of requests allowed
/// during a persistent connection. 0 means unlimited
/// connections.

View File

@ -80,7 +80,7 @@ public:
protected:
ICMPSocket(SocketImpl* pImpl);
/// Creates the Socket and attaches the given SocketImpl.
/// The socket takes owership of the SocketImpl.
/// The socket takes ownership of the SocketImpl.
///
/// The SocketImpl must be a ICMPSocketImpl, otherwise
/// an InvalidArgumentException will be thrown.

View File

@ -373,21 +373,13 @@ private:
#endif
Ptr pImpl() const;
void newIPv4(const void* hostAddr);
void newIPv6(const void* hostAddr);
void newIPv6(const void* hostAddr, Poco::UInt32 scope);
void newIPv4(unsigned prefix);
void newIPv6(unsigned prefix);
void newIPv4();
void newIPv6();
void destruct();
#ifdef POCO_HAVE_ALIGNMENT
@ -413,6 +405,9 @@ private:
};
//
// inlines
//
inline void IPAddress::destruct()
{
#ifdef POCO_HAVE_ALIGNMENT

View File

@ -207,7 +207,7 @@ public:
const std::string& mediaType,
const std::string& filename = "");
/// Returns either default StringPartSource part store or,
/// if the part store factory was provided during contruction,
/// if the part store factory was provided during construction,
/// the one created by PartStoreFactory.
/// Returned part store is allocated on the heap; it is caller's
/// responsibility to delete it after use. Typical use is handler

View File

@ -113,8 +113,8 @@ protected:
class Net_API MailInputStream: public MailIOS, public std::istream
/// This class is used for reading E-Mail messages from a
/// POP3 server. All occurences of "\r\n..\r\n" are replaced with
/// "\r\n.\r\n". The first occurence of "\r\n.\r\n" denotes the end
/// POP3 server. All occurrences of "\r\n..\r\n" are replaced with
/// "\r\n.\r\n". The first occurrence of "\r\n.\r\n" denotes the end
/// of the stream.
{
public:
@ -129,7 +129,7 @@ public:
class Net_API MailOutputStream: public MailIOS, public std::ostream
/// This class is used for writing E-Mail messages to a
/// SMTP server. All occurences of "\r\n.\r\n" are replaced with
/// SMTP server. All occurrences of "\r\n.\r\n" are replaced with
/// "\r\n..\r\n".
{
public:

View File

@ -109,7 +109,7 @@ public:
/// Returns true if the type and subtype match
/// the type and subtype of the given media type.
/// If the MIME type is a range of types it matches
/// any media type withing the range (e.g. "image/*" matches
/// any media type within the range (e.g. "image/*" matches
/// any image media type, "*/*" matches anything).
/// Matching is case insensitive.
@ -117,7 +117,7 @@ public:
/// Returns true if the type and subtype match
/// the given type and subtype.
/// If the MIME type is a range of types it matches
/// any media type withing the range (e.g. "image/*" matches
/// any media type within the range (e.g. "image/*" matches
/// any image media type, "*/*" matches anything).
/// Matching is case insensitive.

View File

@ -30,6 +30,7 @@
#include "Poco/Mutex.h"
#include "Poco/Tuple.h"
#include <map>
#include <ostream>
namespace Poco {
@ -122,7 +123,7 @@ public:
/// Assigns another NetworkInterface.
bool operator < (const NetworkInterface& other) const;
/// Operatorr less-than.
/// Operator less-than.
bool operator == (const NetworkInterface& other) const;
/// Operator equal. Compares interface indices.
@ -149,7 +150,7 @@ public:
/// Returns the interface adapter name.
///
/// On Windows platforms, this is the network adapter LUID.
/// The adapter name is used by some Windows Net APIs like Dhcp.
/// The adapter name is used by some Windows Net APIs like DHCP.
///
/// On other platforms this is the same as name().
@ -182,7 +183,7 @@ public:
/// Returns the broadcast address for this network interface.
const IPAddress& destAddress(unsigned index = 0) const;
/// Returns the IPv4 point-to-point destiation address for this network interface.
/// Returns the IPv4 point-to-point destination address for this network interface.
const MACAddress& macAddress() const;
/// Returns MAC (Media Access Control) address for the interface.
@ -235,6 +236,9 @@ public:
/// The ipVersion argument can be used to specify whether
/// an IPv4 (IPv4_ONLY) or IPv6 (IPv6_ONLY) interface is required,
/// or whether the caller does not care (IPv4_OR_IPv6).
///
/// Throws an InterfaceNotFoundException if an interface
/// with the give name does not exist.
static NetworkInterface forAddress(const IPAddress& address);
/// Returns the NetworkInterface for the given IP address.
@ -342,7 +346,7 @@ inline bool NetworkInterface::operator == (const NetworkInterface& other) const
} } // namespace Poco::Net
Net_API std::ostream& operator<<(std::ostream& os, const Poco::Net::NetworkInterface::MACAddress& mac);
Net_API std::ostream& operator << (std::ostream& ostr, const Poco::Net::NetworkInterface::MACAddress& addr);
#endif // POCO_NET_HAS_INTERFACE

View File

@ -121,7 +121,7 @@ public:
protected:
RawSocket(SocketImpl* pImpl);
/// Creates the Socket and attaches the given SocketImpl.
/// The socket takes owership of the SocketImpl.
/// The socket takes ownership of the SocketImpl.
///
/// The SocketImpl must be a StreamSocketImpl, otherwise
/// an InvalidArgumentException will be thrown.

View File

@ -72,7 +72,7 @@ public:
SYSLOG_NTP = (12<<3), /// ntp subsystem
SYSLOG_LOGAUDIT = (13<<3), /// log audit
SYSLOG_LOGALERT = (14<<3), /// log alert
SYSLOG_CLOCK = (15<<3), /// clock deamon
SYSLOG_CLOCK = (15<<3), /// clock daemon
SYSLOG_LOCAL0 = (16<<3), /// reserved for local use
SYSLOG_LOCAL1 = (17<<3), /// reserved for local use
SYSLOG_LOCAL2 = (18<<3), /// reserved for local use

View File

@ -35,7 +35,7 @@ class MailMessage;
class Net_API SMTPClientSession
/// This class implements an Simple Mail
/// Transfer Procotol (SMTP, RFC 2821)
/// Transfer Protocol (SMTP, RFC 2821)
/// client for sending e-mail messages.
{
public:

View File

@ -38,7 +38,7 @@ public:
/// Creates a server socket.
///
/// The server socket must be bound to
/// and address and put into listening state.
/// an address and put into listening state.
ServerSocket(const Socket& socket);
/// Creates the ServerSocket with the SocketImpl
@ -73,7 +73,7 @@ public:
/// increments the reference count of the SocketImpl.
virtual void bind(const SocketAddress& address, bool reuseAddress = false);
/// Bind a local address to the socket.
/// Binds a local address to the socket.
///
/// This is usually only done when establishing a server
/// socket. TCP clients should not bind a socket to a
@ -83,7 +83,7 @@ public:
/// socket option.
virtual void bind(Poco::UInt16 port, bool reuseAddress = false);
/// Bind a local port to the socket.
/// Binds a local port to the socket.
///
/// This is usually only done when establishing a server
/// socket.
@ -92,7 +92,7 @@ public:
/// socket option.
virtual void bind6(const SocketAddress& address, bool reuseAddress = false, bool ipV6Only = false);
/// Bind a local IPv6 address to the socket.
/// Binds a local IPv6 address to the socket.
///
/// This is usually only done when establishing a server
/// socket. TCP clients should not bind a socket to a
@ -109,7 +109,7 @@ public:
/// a Poco::NotImplementedException will be thrown.
virtual void bind6(Poco::UInt16 port, bool reuseAddress = false, bool ipV6Only = false);
/// Bind a local IPv6 port to the socket.
/// Binds a local IPv6 port to the socket.
///
/// This is usually only done when establishing a server
/// socket.
@ -135,7 +135,7 @@ public:
/// for this socket.
virtual StreamSocket acceptConnection(SocketAddress& clientAddr);
/// Get the next completed connection from the
/// Gets the next completed connection from the
/// socket's completed connection queue.
///
/// If the queue is empty, waits until a connection
@ -147,7 +147,7 @@ public:
/// The client socket's address is returned in clientAddr.
virtual StreamSocket acceptConnection();
/// Get the next completed connection from the
/// Gets the next completed connection from the
/// socket's completed connection queue.
///
/// If the queue is empty, waits until a connection

View File

@ -299,7 +299,7 @@ public:
protected:
Socket(SocketImpl* pImpl);
/// Creates the Socket and attaches the given SocketImpl.
/// The socket takes owership of the SocketImpl.
/// The socket takes ownership of the SocketImpl.
poco_socket_t sockfd() const;
/// Returns the socket descriptor for this socket.

View File

@ -27,6 +27,7 @@
#include "Poco/RefCountedObject.h"
#endif
namespace Poco {
namespace Net {
namespace Impl {
@ -59,20 +60,15 @@ class Net_API IPv4SocketAddressImpl: public SocketAddressImpl
{
public:
IPv4SocketAddressImpl();
IPv4SocketAddressImpl(const struct sockaddr_in* addr);
IPv4SocketAddressImpl(const void* addr, UInt16 port);
IPAddress host() const;
UInt16 port() const;
poco_socklen_t length() const;
const struct sockaddr* addr() const;
int af() const;
Family family() const;
std::string toString() const;
private:
struct sockaddr_in _addr;
@ -120,19 +116,12 @@ class Net_API IPv6SocketAddressImpl: public SocketAddressImpl
{
public:
IPv6SocketAddressImpl(const struct sockaddr_in6* addr);
IPv6SocketAddressImpl(const void* addr, UInt16 port);
IPv6SocketAddressImpl(const void* addr, UInt16 port, UInt32 scope);
IPAddress host() const;
UInt16 port() const;
poco_socklen_t length() const;
const struct sockaddr* addr() const;
int af() const;
private:

View File

@ -96,7 +96,7 @@ public:
class Net_API TimeoutNotification: public SocketNotification
/// This notification is sent if no other event has occured
/// This notification is sent if no other event has occurred
/// for a specified time.
{
public:

View File

@ -83,7 +83,7 @@ class Net_API SocketReactor: public Poco::Runnable
/// becomes writable. The ErrorNotification will be dispatched if
/// there is an error condition on a socket.
///
/// If the timeout expires and no event has occured, a
/// If the timeout expires and no event has occurred, a
/// TimeoutNotification will be dispatched to all event handlers
/// registered for it. This is done in the onTimeout() method
/// which can be overridden by subclasses to perform custom
@ -158,7 +158,7 @@ public:
/// reactor.addEventHandler(obs);
bool hasEventHandler(const Socket& socket, const Poco::AbstractObserver& observer);
/// Returns true if the observer is reistered with SocketReactor for the given socket.
/// Returns true if the observer is registered with SocketReactor for the given socket.
void removeEventHandler(const Socket& socket, const Poco::AbstractObserver& observer);
/// Unregisters an event handler with the SocketReactor.

View File

@ -111,7 +111,7 @@ public:
int sendBytes(Poco::FIFOBuffer& buffer);
/// Sends the contents of the given buffer through
/// the socket. FIFOBuffer has writable/readable transiton
/// the socket. FIFOBuffer has writable/readable transition
/// notifications which may be enabled to notify the caller when
/// the buffer transitions between empty, partially full and
/// full states.
@ -137,7 +137,7 @@ public:
int receiveBytes(Poco::FIFOBuffer& buffer);
/// Receives data from the socket and stores it
/// in buffer. Up to length bytes are received. FIFOBuffer has
/// writable/readable transiton notifications which may be enabled
/// writable/readable transition notifications which may be enabled
/// to notify the caller when the buffer transitions between empty,
/// partially full and full states.
///

View File

@ -80,7 +80,7 @@ class Net_API TCPServer: public Poco::Runnable
public:
TCPServer(TCPServerConnectionFactory::Ptr pFactory, Poco::UInt16 portNumber = 0, TCPServerParams::Ptr pParams = 0);
/// Creates the TCPServer, with ServerSocket listening on the given port.
/// Default port is zero, allowing any availble port. The port number
/// Default port is zero, allowing any available port. The port number
/// can be queried through TCPServer::port() member.
///
/// The server takes ownership of the TCPServerConnectionFactory
@ -188,6 +188,9 @@ private:
};
//
// inlines
//
inline const ServerSocket& TCPServer::socket() const
{
return _socket;

View File

@ -235,6 +235,10 @@ void HTMLForm::prepareSubmit(HTTPRequest& request)
{
request.setChunkedTransferEncoding(true);
}
if (!request.getChunkedTransferEncoding())
{
request.setContentLength(calculateContentLength());
}
}
else
{
@ -250,7 +254,7 @@ void HTMLForm::prepareSubmit(HTTPRequest& request)
std::streamsize HTMLForm::calculateContentLength()
{
if (_boundary.empty())
if (_encoding == ENCODING_MULTIPART && _boundary.empty())
throw HTMLFormException("Form must be prepared");
HTMLFormCountingOutputStream c;
@ -399,7 +403,7 @@ void HTMLForm::writeUrl(std::ostream& ostr)
void HTMLForm::writeMultipart(std::ostream& ostr)
{
HTMLFormCountingOutputStream *costr(dynamic_cast<HTMLFormCountingOutputStream*>(&ostr));
HTMLFormCountingOutputStream* pCountingOutputStream(dynamic_cast<HTMLFormCountingOutputStream*>(&ostr));
MultipartWriter writer(ostr, _boundary);
for (NameValueCollection::ConstIterator it = begin(); it != end(); ++it)
@ -428,17 +432,19 @@ void HTMLForm::writeMultipart(std::ostream& ostr)
header.set("Content-Disposition", disp);
header.set("Content-Type", ita->pSource->mediaType());
writer.nextPart(header);
if (costr)
if (pCountingOutputStream)
{
// count only, don't move stream position
std::streamsize partlen = ita->pSource->getContentLength();
if (partlen != PartSource::UNKNOWN_CONTENT_LENGTH)
costr->addChars(static_cast<int>(partlen));
pCountingOutputStream->addChars(static_cast<int>(partlen));
else
costr->setValid(false);
pCountingOutputStream->setValid(false);
}
else
{
StreamCopier::copyStream(ita->pSource->stream(), ostr);
}
}
writer.close();
_boundary = writer.boundary();

View File

@ -29,7 +29,8 @@ namespace Net {
#else
#pragma pack(1)
#endif
typedef struct _NTPPacketData {
struct NTPPacketData
{
Poco::Int8 mode:3;
Poco::Int8 vn:3;
Poco::Int8 li:2;
@ -43,7 +44,7 @@ typedef struct _NTPPacketData {
Poco::Int64 ots;
Poco::Int64 vts;
Poco::Int64 tts;
} NTPPacketData;
};
#if !defined(POCO_COMPILER_SUN)
#pragma pack(pop)
#else

View File

@ -41,12 +41,13 @@
#include <iostream>
#include <iomanip>
using Poco::NumberFormatter;
using Poco::FastMutex;
using Poco::format;
std::ostream& operator<<(std::ostream& os, const Poco::Net::NetworkInterface::MACAddress& mac)
std::ostream& operator << (std::ostream& os, const Poco::Net::NetworkInterface::MACAddress& mac)
{
std::ios state(0);
state.copyfmt(os);
@ -884,7 +885,7 @@ NetworkInterface::List NetworkInterface::list(bool ipOnly, bool upOnly)
const List& ipList = it->second.addressList();
List::const_iterator ipIt = ipList.begin();
List::const_iterator ipEnd = ipList.end();
for (int counter = 0; ipIt != ipEnd; ++ipIt, ++counter)
for (; ipIt != ipEnd; ++ipIt)
{
IPAddress addr = ipIt->get<NetworkInterface::IP_ADDRESS>();
IPAddress mask = ipIt->get<NetworkInterface::SUBNET_MASK>();
@ -1360,6 +1361,7 @@ namespace Net {
namespace {
NetworkInterface::Type fromNative(u_char nativeType)
{
switch (nativeType)
@ -1380,6 +1382,7 @@ NetworkInterface::Type fromNative(u_char nativeType)
}
}
void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
{
struct sockaddr_dl* sdl = (struct sockaddr_dl*) iface->ifa_addr;
@ -1392,6 +1395,7 @@ void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
impl.setType(fromNative(sdl->sdl_type));
}
} // namespace
@ -1531,6 +1535,7 @@ namespace Net {
namespace {
static NetworkInterface::Type fromNative(unsigned arphrd)
{
switch (arphrd)
@ -1599,6 +1604,7 @@ void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
#endif
}

View File

@ -76,14 +76,14 @@ void RemoteSyslogChannel::open()
{
if (_open) return;
// reset socket for the case that it has been previously closed
_socket = DatagramSocket();
if (_logHost.find(':') != std::string::npos)
_socketAddress = SocketAddress(_logHost);
else
_socketAddress = SocketAddress(_logHost, SYSLOG_PORT);
// reset socket for the case that it has been previously closed
_socket = DatagramSocket(_socketAddress.family());
if (_host.empty())
{
try

View File

@ -23,6 +23,7 @@ namespace Poco {
namespace Net {
namespace Impl {
//
// SocketAddressImpl
//