fixed line endings

This commit is contained in:
Guenter Obiltschnig
2008-02-07 16:08:15 +00:00
parent a99f1aae4d
commit e4d9b3b40f
120 changed files with 32507 additions and 32507 deletions

View File

@@ -1,158 +1,158 @@
//
// AbstractHTTPRequestHandler.h
//
// $Id: //poco/svn/Net/include/Poco/Net/AbstractHTTPRequestHandler.h#2 $
//
// Library: Net
// Package: HTTPServer
// Module: AbstractHTTPRequestHandler
//
// Definition of the AbstractHTTPRequestHandler class.
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_AbstractHTTPRequestHandler_INCLUDED
#define Net_AbstractHTTPRequestHandler_INCLUDED
#include "Poco/Net/HTTPRequestHandler.h"
#include "Poco/Net/HTTPResponse.h"
namespace Poco {
namespace Net {
class HTMLForm;
class Net_API AbstractHTTPRequestHandler: public HTTPRequestHandler
/// The abstract base class for AbstractHTTPRequestHandlers
/// created by HTTPServer.
///
/// Derived classes must override the run() method.
/// Contrary to a HTTPRequestHandler, an AbstractHTTPRequestHandler
/// stores request and response as member variables to avoid having
/// to pass them around as method parameters. Additionally, a
/// HTMLForm object is created for use by subclasses.
///
/// The run() method must perform the complete handling
/// of the HTTP request connection. As soon as the run()
/// method returns, the request handler object is destroyed.
///
/// A new AbstractHTTPRequestHandler object will be created for
/// each new HTTP request that is received by the HTTPServer.
{
public:
AbstractHTTPRequestHandler();
/// Creates the AbstractHTTPRequestHandler.
virtual ~AbstractHTTPRequestHandler();
/// Destroys the AbstractHTTPRequestHandler.
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response);
/// This class implements some common behavior,
/// before calling run() to actually handle the request:
/// - save request and response objects;
/// - call authorize();
/// - if authorize() returns true call run(),
/// else send 401 (Unauthorized) response.
///
/// If run() throws an exception and the response has not been
/// sent yet, sends a 500 (Internal Server Error) response with
/// the exception's display text.
HTTPServerRequest& request();
/// Returns the request.
HTTPServerResponse& response();
/// Returns the response.
HTMLForm& form();
/// Returns a HTMLForm for the given request.
/// The HTMLForm object is created when this
/// member function is executed the first time.
void sendErrorResponse(HTTPResponse::HTTPStatus status, const std::string& message);
/// Sends a HTML error page for the given status code.
/// The given message is added to the page:
/// <HTML>
/// <HEAD>
/// <TITLE>status - reason</TITLE>
/// </HEAD>
/// <BODY>
/// <H1>status - reason</H1>
/// <P>message</P>
/// </BODY>
/// </HTML>
protected:
virtual void run() = 0;
/// Must be overridden by subclasses.
///
/// Handles the given request.
virtual bool authenticate();
/// Check authentication; returns true if okay, false if failed to authenticate.
/// The default implementation always returns true.
///
/// Subclasses can override this member function to perform
/// some form of client or request authentication before
/// the request is actually handled.
private:
HTTPServerRequest* _pRequest;
HTTPServerResponse* _pResponse;
HTMLForm* _pForm;
};
//
// inlines
//
inline HTTPServerRequest& AbstractHTTPRequestHandler::request()
{
poco_check_ptr (_pRequest);
return *_pRequest;
}
inline HTTPServerResponse& AbstractHTTPRequestHandler::response()
{
poco_check_ptr (_pResponse);
return *_pResponse;
}
} } // namespace Poco::Net
#endif // Net_AbstractHTTPRequestHandler_INCLUDED
//
// AbstractHTTPRequestHandler.h
//
// $Id: //poco/svn/Net/include/Poco/Net/AbstractHTTPRequestHandler.h#2 $
//
// Library: Net
// Package: HTTPServer
// Module: AbstractHTTPRequestHandler
//
// Definition of the AbstractHTTPRequestHandler class.
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_AbstractHTTPRequestHandler_INCLUDED
#define Net_AbstractHTTPRequestHandler_INCLUDED
#include "Poco/Net/HTTPRequestHandler.h"
#include "Poco/Net/HTTPResponse.h"
namespace Poco {
namespace Net {
class HTMLForm;
class Net_API AbstractHTTPRequestHandler: public HTTPRequestHandler
/// The abstract base class for AbstractHTTPRequestHandlers
/// created by HTTPServer.
///
/// Derived classes must override the run() method.
/// Contrary to a HTTPRequestHandler, an AbstractHTTPRequestHandler
/// stores request and response as member variables to avoid having
/// to pass them around as method parameters. Additionally, a
/// HTMLForm object is created for use by subclasses.
///
/// The run() method must perform the complete handling
/// of the HTTP request connection. As soon as the run()
/// method returns, the request handler object is destroyed.
///
/// A new AbstractHTTPRequestHandler object will be created for
/// each new HTTP request that is received by the HTTPServer.
{
public:
AbstractHTTPRequestHandler();
/// Creates the AbstractHTTPRequestHandler.
virtual ~AbstractHTTPRequestHandler();
/// Destroys the AbstractHTTPRequestHandler.
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response);
/// This class implements some common behavior,
/// before calling run() to actually handle the request:
/// - save request and response objects;
/// - call authorize();
/// - if authorize() returns true call run(),
/// else send 401 (Unauthorized) response.
///
/// If run() throws an exception and the response has not been
/// sent yet, sends a 500 (Internal Server Error) response with
/// the exception's display text.
HTTPServerRequest& request();
/// Returns the request.
HTTPServerResponse& response();
/// Returns the response.
HTMLForm& form();
/// Returns a HTMLForm for the given request.
/// The HTMLForm object is created when this
/// member function is executed the first time.
void sendErrorResponse(HTTPResponse::HTTPStatus status, const std::string& message);
/// Sends a HTML error page for the given status code.
/// The given message is added to the page:
/// <HTML>
/// <HEAD>
/// <TITLE>status - reason</TITLE>
/// </HEAD>
/// <BODY>
/// <H1>status - reason</H1>
/// <P>message</P>
/// </BODY>
/// </HTML>
protected:
virtual void run() = 0;
/// Must be overridden by subclasses.
///
/// Handles the given request.
virtual bool authenticate();
/// Check authentication; returns true if okay, false if failed to authenticate.
/// The default implementation always returns true.
///
/// Subclasses can override this member function to perform
/// some form of client or request authentication before
/// the request is actually handled.
private:
HTTPServerRequest* _pRequest;
HTTPServerResponse* _pResponse;
HTMLForm* _pForm;
};
//
// inlines
//
inline HTTPServerRequest& AbstractHTTPRequestHandler::request()
{
poco_check_ptr (_pRequest);
return *_pRequest;
}
inline HTTPServerResponse& AbstractHTTPRequestHandler::response()
{
poco_check_ptr (_pResponse);
return *_pResponse;
}
} } // namespace Poco::Net
#endif // Net_AbstractHTTPRequestHandler_INCLUDED

View File

@@ -1,84 +1,84 @@
//
// AsyncSocketChannel.h
//
// $Id: //poco/svn/Net/include/Poco/Net/AsyncSocketChannel.h#2 $
//
// Library: Net
// Package: AsyncIO
// Module: AsyncSocketChannel
//
// Definition of the AsyncSocketChannel class.
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_AsyncSocketChannel_INCLUDED
#define Net_AsyncSocketChannel_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Net/StreamSocket.h"
#include "Poco/AsyncIOChannel.h"
namespace Poco {
namespace Net {
class Net_API AsyncSocketChannel: public Poco::AsyncIOChannel
/// AsyncSocketChannel provides an AsyncIOChannel for a StreamSocket.
///
/// Usage Example:
/// StreamSocket socket(...);
/// AsyncSocketChannel channel(socket);
/// channel.enqueue(new AsyncWriteCommand("Hello", 5));
/// channel.enqueue(new AsyncWriteCommand(", ", 2));
/// ActiveResult<int> result = channel.enqueue(new AsyncWriteCommand("world!", 6));
/// result.wait();
{
public:
AsyncSocketChannel(const StreamSocket& socket);
/// Creates an AsyncSocketChannel using the given StreamSocket.
~AsyncSocketChannel();
/// Destroys the AsyncSocketChannel.
// AsyncIOChannel
int write(const void* buffer, int length);
int read(void* buffer, int length);
private:
AsyncSocketChannel();
StreamSocket _socket;
};
} } // namespace Poco::Net
#endif // Net_AsyncSocketChannel_INCLUDED
//
// AsyncSocketChannel.h
//
// $Id: //poco/svn/Net/include/Poco/Net/AsyncSocketChannel.h#2 $
//
// Library: Net
// Package: AsyncIO
// Module: AsyncSocketChannel
//
// Definition of the AsyncSocketChannel class.
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_AsyncSocketChannel_INCLUDED
#define Net_AsyncSocketChannel_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Net/StreamSocket.h"
#include "Poco/AsyncIOChannel.h"
namespace Poco {
namespace Net {
class Net_API AsyncSocketChannel: public Poco::AsyncIOChannel
/// AsyncSocketChannel provides an AsyncIOChannel for a StreamSocket.
///
/// Usage Example:
/// StreamSocket socket(...);
/// AsyncSocketChannel channel(socket);
/// channel.enqueue(new AsyncWriteCommand("Hello", 5));
/// channel.enqueue(new AsyncWriteCommand(", ", 2));
/// ActiveResult<int> result = channel.enqueue(new AsyncWriteCommand("world!", 6));
/// result.wait();
{
public:
AsyncSocketChannel(const StreamSocket& socket);
/// Creates an AsyncSocketChannel using the given StreamSocket.
~AsyncSocketChannel();
/// Destroys the AsyncSocketChannel.
// AsyncIOChannel
int write(const void* buffer, int length);
int read(void* buffer, int length);
private:
AsyncSocketChannel();
StreamSocket _socket;
};
} } // namespace Poco::Net
#endif // Net_AsyncSocketChannel_INCLUDED

View File

@@ -1,142 +1,142 @@
//
// HTTPServerRequestImpl.h
//
// $Id: //poco/svn/Net/include/Poco/Net/HTTPServerRequestImpl.h#2 $
//
// Library: Net
// Package: HTTPServer
// Module: HTTPServerRequestImpl
//
// Definition of the HTTPServerRequestImpl class.
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_HTTPServerRequestImpl_INCLUDED
#define Net_HTTPServerRequestImpl_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Net/SocketAddress.h"
#include <istream>
namespace Poco {
namespace Net {
class HTTPServerSession;
class HTTPServerParams;
class Net_API HTTPServerRequestImpl: public HTTPServerRequest
/// This subclass of HTTPServerRequest is used for
/// representing server-side HTTP requests.
///
/// A HTTPServerRequest is passed to the
/// handleRequest() method of HTTPRequestHandler.
{
public:
HTTPServerRequestImpl(HTTPServerResponse& response, HTTPServerSession& session, HTTPServerParams* pParams);
/// Creates the HTTPServerRequestImpl, using the
/// given HTTPServerSession.
~HTTPServerRequestImpl();
/// Destroys the HTTPServerRequestImpl.
std::istream& stream();
/// Returns the input stream for reading
/// the request body.
///
/// The stream is valid until the HTTPServerRequestImpl
/// object is destroyed.
bool expectContinue() const;
/// Returns true if the client expects a
/// 100 Continue response.
const SocketAddress& clientAddress() const;
/// Returns the client's address.
const SocketAddress& serverAddress() const;
/// Returns the server's address.
const HTTPServerParams& serverParams() const;
/// Returns a reference to the server parameters.
HTTPServerResponse& response() const;
/// Returns a reference to the associated response.
private:
HTTPServerResponse& _response;
std::istream* _pStream;
HTTPServerParams* _pParams;
SocketAddress _clientAddress;
SocketAddress _serverAddress;
};
//
// inlines
//
inline std::istream& HTTPServerRequestImpl::stream()
{
poco_check_ptr (_pStream);
return *_pStream;
}
inline const SocketAddress& HTTPServerRequestImpl::clientAddress() const
{
return _clientAddress;
}
inline const SocketAddress& HTTPServerRequestImpl::serverAddress() const
{
return _serverAddress;
}
inline const HTTPServerParams& HTTPServerRequestImpl::serverParams() const
{
return *_pParams;
}
inline HTTPServerResponse& HTTPServerRequestImpl::response() const
{
return _response;
}
} } // namespace Poco::Net
#endif // Net_HTTPServerRequestImpl_INCLUDED
//
// HTTPServerRequestImpl.h
//
// $Id: //poco/svn/Net/include/Poco/Net/HTTPServerRequestImpl.h#2 $
//
// Library: Net
// Package: HTTPServer
// Module: HTTPServerRequestImpl
//
// Definition of the HTTPServerRequestImpl class.
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_HTTPServerRequestImpl_INCLUDED
#define Net_HTTPServerRequestImpl_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Net/SocketAddress.h"
#include <istream>
namespace Poco {
namespace Net {
class HTTPServerSession;
class HTTPServerParams;
class Net_API HTTPServerRequestImpl: public HTTPServerRequest
/// This subclass of HTTPServerRequest is used for
/// representing server-side HTTP requests.
///
/// A HTTPServerRequest is passed to the
/// handleRequest() method of HTTPRequestHandler.
{
public:
HTTPServerRequestImpl(HTTPServerResponse& response, HTTPServerSession& session, HTTPServerParams* pParams);
/// Creates the HTTPServerRequestImpl, using the
/// given HTTPServerSession.
~HTTPServerRequestImpl();
/// Destroys the HTTPServerRequestImpl.
std::istream& stream();
/// Returns the input stream for reading
/// the request body.
///
/// The stream is valid until the HTTPServerRequestImpl
/// object is destroyed.
bool expectContinue() const;
/// Returns true if the client expects a
/// 100 Continue response.
const SocketAddress& clientAddress() const;
/// Returns the client's address.
const SocketAddress& serverAddress() const;
/// Returns the server's address.
const HTTPServerParams& serverParams() const;
/// Returns a reference to the server parameters.
HTTPServerResponse& response() const;
/// Returns a reference to the associated response.
private:
HTTPServerResponse& _response;
std::istream* _pStream;
HTTPServerParams* _pParams;
SocketAddress _clientAddress;
SocketAddress _serverAddress;
};
//
// inlines
//
inline std::istream& HTTPServerRequestImpl::stream()
{
poco_check_ptr (_pStream);
return *_pStream;
}
inline const SocketAddress& HTTPServerRequestImpl::clientAddress() const
{
return _clientAddress;
}
inline const SocketAddress& HTTPServerRequestImpl::serverAddress() const
{
return _serverAddress;
}
inline const HTTPServerParams& HTTPServerRequestImpl::serverParams() const
{
return *_pParams;
}
inline HTTPServerResponse& HTTPServerRequestImpl::response() const
{
return _response;
}
} } // namespace Poco::Net
#endif // Net_HTTPServerRequestImpl_INCLUDED

View File

@@ -1,147 +1,147 @@
//
// HTTPServerResponseImpl.h
//
// $Id: //poco/svn/Net/include/Poco/Net/HTTPServerResponseImpl.h#2 $
//
// Library: Net
// Package: HTTPServer
// Module: HTTPServerResponseImpl
//
// Definition of the HTTPServerResponseImpl class.
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_HTTPServerResponseImpl_INCLUDED
#define Net_HTTPServerResponseImpl_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Net/HTTPServerResponse.h"
namespace Poco {
namespace Net {
class HTTPServerSession;
class HTTPCookie;
class Net_API HTTPServerResponseImpl: public HTTPServerResponse
/// This subclass of HTTPServerResponse is used for
/// representing server-side HTTP responses.
///
/// A HTTPServerResponse is passed to the
/// handleRequest() method of HTTPRequestHandler.
///
/// handleRequest() must set a status code
/// and optional reason phrase, set headers
/// as necessary, and provide a message body.
{
public:
HTTPServerResponseImpl(HTTPServerSession& session);
/// Creates the HTTPServerResponseImpl.
~HTTPServerResponseImpl();
/// Destroys the HTTPServerResponseImpl.
void sendContinue();
/// Sends a 100 Continue response to the
/// client.
std::ostream& send();
/// Sends the response header to the client and
/// returns an output stream for sending the
/// response body.
///
/// The returned stream is valid until the response
/// object is destroyed.
///
/// Must not be called after sendFile(), sendBuffer()
/// or redirect() has been called.
void sendFile(const std::string& path, const std::string& mediaType);
/// Sends the response header to the client, followed
/// by the content of the given file.
///
/// Must not be called after send(), sendBuffer()
/// or redirect() has been called.
///
/// Throws a FileNotFoundException if the file
/// cannot be found, or an OpenFileException if
/// the file cannot be opened.
void sendBuffer(const void* pBuffer, std::size_t length);
/// Sends the response header to the client, followed
/// by the contents of the given buffer.
///
/// The Content-Length header of the response is set
/// to length and chunked transfer encoding is disabled.
///
/// If both the HTTP message header and body (from the
/// given buffer) fit into one single network packet, the
/// complete response can be sent in one network packet.
///
/// Must not be called after send(), sendFile()
/// or redirect() has been called.
void redirect(const std::string& uri);
/// Sets the status code to 302 (Found)
/// and sets the "Location" header field
/// to the given URI, which according to
/// the HTTP specification, must be absolute.
///
/// Must not be called after send() has been called.
void requireAuthentication(const std::string& realm);
/// Sets the status code to 401 (Unauthorized)
/// and sets the "WWW-Authenticate" header field
/// according to the given realm.
bool sent() const;
/// Returns true if the response (header) has been sent.
private:
HTTPServerSession& _session;
std::ostream* _pStream;
};
//
// inlines
//
inline bool HTTPServerResponseImpl::sent() const
{
return _pStream != 0;
}
} } // namespace Poco::Net
#endif // Net_HTTPServerResponseImpl_INCLUDED
//
// HTTPServerResponseImpl.h
//
// $Id: //poco/svn/Net/include/Poco/Net/HTTPServerResponseImpl.h#2 $
//
// Library: Net
// Package: HTTPServer
// Module: HTTPServerResponseImpl
//
// Definition of the HTTPServerResponseImpl class.
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_HTTPServerResponseImpl_INCLUDED
#define Net_HTTPServerResponseImpl_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Net/HTTPServerResponse.h"
namespace Poco {
namespace Net {
class HTTPServerSession;
class HTTPCookie;
class Net_API HTTPServerResponseImpl: public HTTPServerResponse
/// This subclass of HTTPServerResponse is used for
/// representing server-side HTTP responses.
///
/// A HTTPServerResponse is passed to the
/// handleRequest() method of HTTPRequestHandler.
///
/// handleRequest() must set a status code
/// and optional reason phrase, set headers
/// as necessary, and provide a message body.
{
public:
HTTPServerResponseImpl(HTTPServerSession& session);
/// Creates the HTTPServerResponseImpl.
~HTTPServerResponseImpl();
/// Destroys the HTTPServerResponseImpl.
void sendContinue();
/// Sends a 100 Continue response to the
/// client.
std::ostream& send();
/// Sends the response header to the client and
/// returns an output stream for sending the
/// response body.
///
/// The returned stream is valid until the response
/// object is destroyed.
///
/// Must not be called after sendFile(), sendBuffer()
/// or redirect() has been called.
void sendFile(const std::string& path, const std::string& mediaType);
/// Sends the response header to the client, followed
/// by the content of the given file.
///
/// Must not be called after send(), sendBuffer()
/// or redirect() has been called.
///
/// Throws a FileNotFoundException if the file
/// cannot be found, or an OpenFileException if
/// the file cannot be opened.
void sendBuffer(const void* pBuffer, std::size_t length);
/// Sends the response header to the client, followed
/// by the contents of the given buffer.
///
/// The Content-Length header of the response is set
/// to length and chunked transfer encoding is disabled.
///
/// If both the HTTP message header and body (from the
/// given buffer) fit into one single network packet, the
/// complete response can be sent in one network packet.
///
/// Must not be called after send(), sendFile()
/// or redirect() has been called.
void redirect(const std::string& uri);
/// Sets the status code to 302 (Found)
/// and sets the "Location" header field
/// to the given URI, which according to
/// the HTTP specification, must be absolute.
///
/// Must not be called after send() has been called.
void requireAuthentication(const std::string& realm);
/// Sets the status code to 401 (Unauthorized)
/// and sets the "WWW-Authenticate" header field
/// according to the given realm.
bool sent() const;
/// Returns true if the response (header) has been sent.
private:
HTTPServerSession& _session;
std::ostream* _pStream;
};
//
// inlines
//
inline bool HTTPServerResponseImpl::sent() const
{
return _pStream != 0;
}
} } // namespace Poco::Net
#endif // Net_HTTPServerResponseImpl_INCLUDED

View File

@@ -1,169 +1,169 @@
//
// RemoteSyslogChannel.h
//
// $Id: //poco/svn/Net/include/Poco/Net/RemoteSyslogChannel.h#2 $
//
// Library: Net
// Package: Logging
// Module: RemoteSyslogChannel
//
// Definition of the RemoteSyslogChannel class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_RemoteSyslogChannel_INCLUDED
#define Net_RemoteSyslogChannel_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Channel.h"
#include "Poco/Net/DatagramSocket.h"
namespace Poco {
namespace Net {
class Net_API RemoteSyslogChannel: public Poco::Channel
/// This Channel implements remote syslog logging over UDP according
/// to the syslog Working Group Internet Draft:
/// "The syslog Protocol" <http://www.ietf.org/internet-drafts/draft-ietf-syslog-protocol-17.txt>,
/// and "Transmission of syslog messages over UDP" <http://www.ietf.org/internet-drafts/draft-ietf-syslog-transport-udp-07.txt>.
///
/// In addition, RemoteSyslogChannel also supports the "old" BSD syslog
/// protocol, as described in RFC 3164.
{
public:
static const std::string BSD_TIMEFORMAT;
static const std::string SYSLOG_TIMEFORMAT;
enum Severity
{
SYSLOG_EMERGENCY = 0, /// Emergency: system is unusable
SYSLOG_ALERT = 1, /// Alert: action must be taken immediately
SYSLOG_CRITICAL = 2, /// Critical: critical conditions
SYSLOG_ERROR = 3, /// Error: error conditions
SYSLOG_WARNING = 4, /// Warning: warning conditions
SYSLOG_NOTICE = 5, /// Notice: normal but significant condition
SYSLOG_INFORMATIONAL = 6, /// Informational: informational messages
SYSLOG_DEBUG = 7 /// Debug: debug-level messages
};
enum Facility
{
SYSLOG_KERN = ( 0<<3), /// kernel messages
SYSLOG_USER = ( 1<<3), /// random user-level messages
SYSLOG_MAIL = ( 2<<3), /// mail system
SYSLOG_DAEMON = ( 3<<3), /// system daemons
SYSLOG_AUTH = ( 4<<3), /// security/authorization messages
SYSLOG_SYSLOG = ( 5<<3), /// messages generated internally by syslogd
SYSLOG_LPR = ( 6<<3), /// line printer subsystem
SYSLOG_NEWS = ( 7<<3), /// network news subsystem
SYSLOG_UUCP = ( 8<<3), /// UUCP subsystem
SYSLOG_CRON = ( 9<<3), /// clock daemon
SYSLOG_AUTHPRIV = (10<<3), /// security/authorization messages (private)
SYSLOG_FTP = (11<<3), /// ftp daemon
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_LOCAL0 = (16<<3), /// reserved for local use
SYSLOG_LOCAL1 = (17<<3), /// reserved for local use
SYSLOG_LOCAL2 = (18<<3), /// reserved for local use
SYSLOG_LOCAL3 = (19<<3), /// reserved for local use
SYSLOG_LOCAL4 = (20<<3), /// reserved for local use
SYSLOG_LOCAL5 = (21<<3), /// reserved for local use
SYSLOG_LOCAL6 = (22<<3), /// reserved for local use
SYSLOG_LOCAL7 = (23<<3) /// reserved for local use
};
enum
{
SYSLOG_PORT = 514
};
RemoteSyslogChannel();
/// Creates a RemoteSyslogChannel.
RemoteSyslogChannel(const std::string& address, const std::string& name, int facility = SYSLOG_USER, bool bsdFormat = false);
/// Creates a RemoteSyslogChannel with the given target address, name, and facility.
/// If bsdFormat is true, messages are formatted according to RFC 3164.
void open();
/// Opens the RemoteSyslogChannel.
void close();
/// Closes the RemoteSyslogChannel.
void log(const Message& msg);
/// Sends the message's text to the syslog service.
void setProperty(const std::string& name, const std::string& value);
/// Sets the property with the given value.
///
/// The following properties are supported:
/// * name: The name used to identify the source of log messages.
/// * facility: The facility added to each log message. See the Facility enumeration for a list of supported values.
/// The LOG_ prefix can be omitted and values are case insensitive (e.g. a facility value "mail" is recognized as SYSLOG_MAIL)
/// * format: "bsd" (RFC 3164 format) or "new" (default)
/// * loghost: The target IP address or host name where log messages are sent. Optionally, a port number (separated
/// by a colon) can also be specified.
/// * host: (optional) Host name included in syslog messages. If not specified, the host's real domain name or
/// IP address will be used.
std::string getProperty(const std::string& name) const;
/// Returns the value of the property with the given name.
static void registerChannel();
/// Registers the channel with the global LoggingFactory.
static const std::string PROP_NAME;
static const std::string PROP_FACILITY;
static const std::string PROP_FORMAT;
static const std::string PROP_LOGHOST;
static const std::string PROP_HOST;
protected:
~RemoteSyslogChannel();
static int getPrio(const Message& msg);
private:
std::string _logHost;
std::string _name;
std::string _host;
int _facility;
bool _bsdFormat;
DatagramSocket _socket;
bool _open;
};
} } // namespace Poco::Net
#endif // Net_RemoteSyslogChannel_INCLUDED
//
// RemoteSyslogChannel.h
//
// $Id: //poco/svn/Net/include/Poco/Net/RemoteSyslogChannel.h#2 $
//
// Library: Net
// Package: Logging
// Module: RemoteSyslogChannel
//
// Definition of the RemoteSyslogChannel class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_RemoteSyslogChannel_INCLUDED
#define Net_RemoteSyslogChannel_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Channel.h"
#include "Poco/Net/DatagramSocket.h"
namespace Poco {
namespace Net {
class Net_API RemoteSyslogChannel: public Poco::Channel
/// This Channel implements remote syslog logging over UDP according
/// to the syslog Working Group Internet Draft:
/// "The syslog Protocol" <http://www.ietf.org/internet-drafts/draft-ietf-syslog-protocol-17.txt>,
/// and "Transmission of syslog messages over UDP" <http://www.ietf.org/internet-drafts/draft-ietf-syslog-transport-udp-07.txt>.
///
/// In addition, RemoteSyslogChannel also supports the "old" BSD syslog
/// protocol, as described in RFC 3164.
{
public:
static const std::string BSD_TIMEFORMAT;
static const std::string SYSLOG_TIMEFORMAT;
enum Severity
{
SYSLOG_EMERGENCY = 0, /// Emergency: system is unusable
SYSLOG_ALERT = 1, /// Alert: action must be taken immediately
SYSLOG_CRITICAL = 2, /// Critical: critical conditions
SYSLOG_ERROR = 3, /// Error: error conditions
SYSLOG_WARNING = 4, /// Warning: warning conditions
SYSLOG_NOTICE = 5, /// Notice: normal but significant condition
SYSLOG_INFORMATIONAL = 6, /// Informational: informational messages
SYSLOG_DEBUG = 7 /// Debug: debug-level messages
};
enum Facility
{
SYSLOG_KERN = ( 0<<3), /// kernel messages
SYSLOG_USER = ( 1<<3), /// random user-level messages
SYSLOG_MAIL = ( 2<<3), /// mail system
SYSLOG_DAEMON = ( 3<<3), /// system daemons
SYSLOG_AUTH = ( 4<<3), /// security/authorization messages
SYSLOG_SYSLOG = ( 5<<3), /// messages generated internally by syslogd
SYSLOG_LPR = ( 6<<3), /// line printer subsystem
SYSLOG_NEWS = ( 7<<3), /// network news subsystem
SYSLOG_UUCP = ( 8<<3), /// UUCP subsystem
SYSLOG_CRON = ( 9<<3), /// clock daemon
SYSLOG_AUTHPRIV = (10<<3), /// security/authorization messages (private)
SYSLOG_FTP = (11<<3), /// ftp daemon
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_LOCAL0 = (16<<3), /// reserved for local use
SYSLOG_LOCAL1 = (17<<3), /// reserved for local use
SYSLOG_LOCAL2 = (18<<3), /// reserved for local use
SYSLOG_LOCAL3 = (19<<3), /// reserved for local use
SYSLOG_LOCAL4 = (20<<3), /// reserved for local use
SYSLOG_LOCAL5 = (21<<3), /// reserved for local use
SYSLOG_LOCAL6 = (22<<3), /// reserved for local use
SYSLOG_LOCAL7 = (23<<3) /// reserved for local use
};
enum
{
SYSLOG_PORT = 514
};
RemoteSyslogChannel();
/// Creates a RemoteSyslogChannel.
RemoteSyslogChannel(const std::string& address, const std::string& name, int facility = SYSLOG_USER, bool bsdFormat = false);
/// Creates a RemoteSyslogChannel with the given target address, name, and facility.
/// If bsdFormat is true, messages are formatted according to RFC 3164.
void open();
/// Opens the RemoteSyslogChannel.
void close();
/// Closes the RemoteSyslogChannel.
void log(const Message& msg);
/// Sends the message's text to the syslog service.
void setProperty(const std::string& name, const std::string& value);
/// Sets the property with the given value.
///
/// The following properties are supported:
/// * name: The name used to identify the source of log messages.
/// * facility: The facility added to each log message. See the Facility enumeration for a list of supported values.
/// The LOG_ prefix can be omitted and values are case insensitive (e.g. a facility value "mail" is recognized as SYSLOG_MAIL)
/// * format: "bsd" (RFC 3164 format) or "new" (default)
/// * loghost: The target IP address or host name where log messages are sent. Optionally, a port number (separated
/// by a colon) can also be specified.
/// * host: (optional) Host name included in syslog messages. If not specified, the host's real domain name or
/// IP address will be used.
std::string getProperty(const std::string& name) const;
/// Returns the value of the property with the given name.
static void registerChannel();
/// Registers the channel with the global LoggingFactory.
static const std::string PROP_NAME;
static const std::string PROP_FACILITY;
static const std::string PROP_FORMAT;
static const std::string PROP_LOGHOST;
static const std::string PROP_HOST;
protected:
~RemoteSyslogChannel();
static int getPrio(const Message& msg);
private:
std::string _logHost;
std::string _name;
std::string _host;
int _facility;
bool _bsdFormat;
DatagramSocket _socket;
bool _open;
};
} } // namespace Poco::Net
#endif // Net_RemoteSyslogChannel_INCLUDED

View File

@@ -1,114 +1,114 @@
//
// RemoteSyslogListener.h
//
// $Id: //poco/svn/Net/include/Poco/Net/RemoteSyslogListener.h#2 $
//
// Library: Net
// Package: Logging
// Module: RemoteSyslogListener
//
// Definition of the RemoteSyslogListener class.
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_RemoteSyslogListener_INCLUDED
#define Net_RemoteSyslogListener_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Thread.h"
#include "Poco/SplitterChannel.h"
#include "Poco/NotificationQueue.h"
namespace Poco {
namespace Net {
class RemoteUDPListener;
class SyslogParser;
class Net_API RemoteSyslogListener: public Poco::SplitterChannel
/// RemoteSyslogListener implents listening for syslog messages
/// sent over UDP, according to the syslog Working Group Internet Draft:
/// "The syslog Protocol" <http://www.ietf.org/internet-drafts/draft-ietf-syslog-protocol-17.txt>,
/// and "Transmission of syslog messages over UDP" <http://www.ietf.org/internet-drafts/draft-ietf-syslog-transport-udp-07.txt>.
///
/// In addition, RemoteSyslogListener also supports the "old" BSD syslog
/// protocol, as described in RFC 3164.
///
/// The RemoteSyslogListener is a subclass of Poco::SplitterChannel.
/// Every received log message is sent to the channels registered
/// with addChannel() or the "channel" property.
{
public:
RemoteSyslogListener();
/// Creates the RemoteSyslogListener.
RemoteSyslogListener(Poco::UInt16 port);
/// Creates the RemoteSyslogListener.
void setProperty(const std::string& name, const std::string& value);
/// Sets the property with the given value.
///
/// The following properties are supported:
/// * port: The UDP port number where to listen for UDP.
std::string getProperty(const std::string& name) const;
/// Returns the value of the property with the given name.
void open();
/// Starts the listener.
void close();
/// Stops the listener.
static void registerChannel();
/// Registers the channel with the global LoggingFactory.
static const std::string PROP_PORT;
protected:
~RemoteSyslogListener();
/// Destroys the RemoteSyslogListener.
private:
RemoteUDPListener* _pListener;
SyslogParser* _pParser;
Poco::Thread _listener;
Poco::Thread _parser;
Poco::NotificationQueue _queue;
Poco::UInt16 _port;
};
} } // namespace Poco::Net
#endif // Net_RemoteSyslogListener_INCLUDED
//
// RemoteSyslogListener.h
//
// $Id: //poco/svn/Net/include/Poco/Net/RemoteSyslogListener.h#2 $
//
// Library: Net
// Package: Logging
// Module: RemoteSyslogListener
//
// Definition of the RemoteSyslogListener class.
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_RemoteSyslogListener_INCLUDED
#define Net_RemoteSyslogListener_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Thread.h"
#include "Poco/SplitterChannel.h"
#include "Poco/NotificationQueue.h"
namespace Poco {
namespace Net {
class RemoteUDPListener;
class SyslogParser;
class Net_API RemoteSyslogListener: public Poco::SplitterChannel
/// RemoteSyslogListener implents listening for syslog messages
/// sent over UDP, according to the syslog Working Group Internet Draft:
/// "The syslog Protocol" <http://www.ietf.org/internet-drafts/draft-ietf-syslog-protocol-17.txt>,
/// and "Transmission of syslog messages over UDP" <http://www.ietf.org/internet-drafts/draft-ietf-syslog-transport-udp-07.txt>.
///
/// In addition, RemoteSyslogListener also supports the "old" BSD syslog
/// protocol, as described in RFC 3164.
///
/// The RemoteSyslogListener is a subclass of Poco::SplitterChannel.
/// Every received log message is sent to the channels registered
/// with addChannel() or the "channel" property.
{
public:
RemoteSyslogListener();
/// Creates the RemoteSyslogListener.
RemoteSyslogListener(Poco::UInt16 port);
/// Creates the RemoteSyslogListener.
void setProperty(const std::string& name, const std::string& value);
/// Sets the property with the given value.
///
/// The following properties are supported:
/// * port: The UDP port number where to listen for UDP.
std::string getProperty(const std::string& name) const;
/// Returns the value of the property with the given name.
void open();
/// Starts the listener.
void close();
/// Stops the listener.
static void registerChannel();
/// Registers the channel with the global LoggingFactory.
static const std::string PROP_PORT;
protected:
~RemoteSyslogListener();
/// Destroys the RemoteSyslogListener.
private:
RemoteUDPListener* _pListener;
SyslogParser* _pParser;
Poco::Thread _listener;
Poco::Thread _parser;
Poco::NotificationQueue _queue;
Poco::UInt16 _port;
};
} } // namespace Poco::Net
#endif // Net_RemoteSyslogListener_INCLUDED

View File

@@ -1,130 +1,130 @@
//
// SMTPChannel.h
//
// $Id: //poco/svn/Net/include/Poco/Net/SMTPChannel.h#1 $
//
// Library: Net
// Package: Logging
// Module: SMTPChannel
//
// Definition of the SMTPChannel class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_SMTPChannel_INCLUDED
#define Net_SMTPChannel_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Channel.h"
#include "Poco/String.h"
namespace Poco {
namespace Net {
class Net_API SMTPChannel: public Poco::Channel
/// This Channel implements SMTP (email) logging.
{
public:
SMTPChannel();
/// Creates a SMTPChannel.
SMTPChannel(const std::string& mailhost, const std::string& sender, const std::string& recipient);
/// Creates a SMTPChannel with the given target mailhost, sender, and recipient.
void open();
/// Opens the SMTPChannel.
void close();
/// Closes the SMTPChannel.
void log(const Message& msg);
/// Sends the message's text to the recipient.
void setProperty(const std::string& name, const std::string& value);
/// Sets the property with the given value.
///
/// The following properties are supported:
/// * mailhost: The SMTP server. Default is "localhost".
/// * sender: The sender address.
/// * recipient: The recipient address.
/// * local: If true, local time is used. Default is true.
/// * attachment: Filename of the file to attach.
/// * type: Content type of the file to attach.
/// * delete: Boolean value indicating whether to delete
/// the attachment file after sending.
/// * throw: Boolean value indicating whether to throw
/// exception upon failure.
std::string getProperty(const std::string& name) const;
/// Returns the value of the property with the given name.
static void registerChannel();
/// Registers the channel with the global LoggingFactory.
static const std::string PROP_MAILHOST;
static const std::string PROP_SENDER;
static const std::string PROP_RECIPIENT;
static const std::string PROP_LOCAL;
static const std::string PROP_ATTACHMENT;
static const std::string PROP_TYPE;
static const std::string PROP_DELETE;
static const std::string PROP_THROW;
protected:
~SMTPChannel();
private:
bool isTrue(const std::string& value) const;
std::string _mailHost;
std::string _sender;
std::string _recipient;
bool _local;
std::string _attachment;
std::string _type;
bool _delete;
bool _throw;
};
inline bool SMTPChannel::isTrue(const std::string& value) const
{
return ((0 == icompare(value, "true")) ||
(0 == icompare(value, "t")) ||
(0 == icompare(value, "yes")) ||
(0 == icompare(value, "y")));
}
} } // namespace Poco::Net
#endif // Net_SMTPChannel_INCLUDED
//
// SMTPChannel.h
//
// $Id: //poco/svn/Net/include/Poco/Net/SMTPChannel.h#1 $
//
// Library: Net
// Package: Logging
// Module: SMTPChannel
//
// Definition of the SMTPChannel class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Net_SMTPChannel_INCLUDED
#define Net_SMTPChannel_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Channel.h"
#include "Poco/String.h"
namespace Poco {
namespace Net {
class Net_API SMTPChannel: public Poco::Channel
/// This Channel implements SMTP (email) logging.
{
public:
SMTPChannel();
/// Creates a SMTPChannel.
SMTPChannel(const std::string& mailhost, const std::string& sender, const std::string& recipient);
/// Creates a SMTPChannel with the given target mailhost, sender, and recipient.
void open();
/// Opens the SMTPChannel.
void close();
/// Closes the SMTPChannel.
void log(const Message& msg);
/// Sends the message's text to the recipient.
void setProperty(const std::string& name, const std::string& value);
/// Sets the property with the given value.
///
/// The following properties are supported:
/// * mailhost: The SMTP server. Default is "localhost".
/// * sender: The sender address.
/// * recipient: The recipient address.
/// * local: If true, local time is used. Default is true.
/// * attachment: Filename of the file to attach.
/// * type: Content type of the file to attach.
/// * delete: Boolean value indicating whether to delete
/// the attachment file after sending.
/// * throw: Boolean value indicating whether to throw
/// exception upon failure.
std::string getProperty(const std::string& name) const;
/// Returns the value of the property with the given name.
static void registerChannel();
/// Registers the channel with the global LoggingFactory.
static const std::string PROP_MAILHOST;
static const std::string PROP_SENDER;
static const std::string PROP_RECIPIENT;
static const std::string PROP_LOCAL;
static const std::string PROP_ATTACHMENT;
static const std::string PROP_TYPE;
static const std::string PROP_DELETE;
static const std::string PROP_THROW;
protected:
~SMTPChannel();
private:
bool isTrue(const std::string& value) const;
std::string _mailHost;
std::string _sender;
std::string _recipient;
bool _local;
std::string _attachment;
std::string _type;
bool _delete;
bool _throw;
};
inline bool SMTPChannel::isTrue(const std::string& value) const
{
return ((0 == icompare(value, "true")) ||
(0 == icompare(value, "t")) ||
(0 == icompare(value, "yes")) ||
(0 == icompare(value, "y")));
}
} } // namespace Poco::Net
#endif // Net_SMTPChannel_INCLUDED