connectionhttpproxy.h
/*
Copyright (c) 2004-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef CONNECTIONHTTPPROXY_H__
#define CONNECTIONHTTPPROXY_H__
#include "gloox.h"
#include "connectionbase.h"
#include "logsink.h"
#include <string>
namespace gloox
{
class GLOOX_API ConnectionHTTPProxy : public ConnectionBase, public ConnectionDataHandler
{
public:
ConnectionHTTPProxy( ConnectionBase* connection, const LogSink& logInstance,
const std::string& server, int port = -1 );
ConnectionHTTPProxy( ConnectionDataHandler* cdh, ConnectionBase* connection,
const LogSink& logInstance,
const std::string& server, int port = -1 );
virtual ~ConnectionHTTPProxy();
// reimplemented from ConnectionBase
virtual ConnectionError connect();
// reimplemented from ConnectionBase
virtual ConnectionError recv( int timeout = -1 );
// reimplemented from ConnectionBase
virtual bool send( const std::string& data );
// reimplemented from ConnectionBase
virtual ConnectionError receive();
// reimplemented from ConnectionBase
virtual void disconnect();
// reimplemented from ConnectionBase
virtual void cleanup();
// reimplemented from ConnectionBase
virtual void getStatistics( long int &totalIn, long int &totalOut );
// reimplemented from ConnectionDataHandler
virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data );
// reimplemented from ConnectionDataHandler
virtual void handleConnect( const ConnectionBase* connection );
// reimplemented from ConnectionDataHandler
virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason );
// reimplemented from ConnectionDataHandler
virtual ConnectionBase* newInstance() const;
void setServer( const std::string& host, int port = -1 )
{ m_server = host; m_port = port; }
void setProxyAuth( const std::string& user, const std::string& password )
{ m_proxyUser = user; m_proxyPwd = password; }
void setConnectionImpl( ConnectionBase* connection );
void setHTTP11( bool http11 ) { m_http11 = http11; }
private:
ConnectionHTTPProxy &operator=( const ConnectionHTTPProxy& );
ConnectionBase* m_connection;
const LogSink& m_logInstance;
std::string m_proxyUser;
std::string m_proxyPwd;
std::string m_proxyHandshakeBuffer;
bool m_http11;
};
}
#endif // CONNECTIONHTTPPROXY_H__
gloox::ConnectionBase
An abstract base class for a connection.
Definition connectionbase.h:35
gloox::ConnectionBase::port
int port() const
Definition connectionbase.h:121
gloox::ConnectionBase::server
const std::string & server() const
Definition connectionbase.h:115
gloox::ConnectionBase::m_port
int m_port
Definition connectionbase.h:161
gloox::ConnectionBase::m_server
std::string m_server
Definition connectionbase.h:158
gloox::ConnectionBase::ConnectionBase
ConnectionBase(ConnectionDataHandler *cdh)
Definition connectionbase.h:42
gloox::ConnectionDataHandler
This is an abstract base class to receive events from a ConnectionBase-derived object.
Definition connectiondatahandler.h:36
gloox::ConnectionHTTPProxy
This is an implementation of a simple HTTP Proxying connection.
Definition connectionhttpproxy.h:54
gloox::ConnectionHTTPProxy::setHTTP11
void setHTTP11(bool http11)
Definition connectionhttpproxy.h:153
gloox::ConnectionHTTPProxy::handleDisconnect
virtual void handleDisconnect(const ConnectionBase *connection, ConnectionError reason)
Definition connectionhttpproxy.cpp:205
gloox::ConnectionHTTPProxy::recv
virtual ConnectionError recv(int timeout=-1)
Definition connectionhttpproxy.cpp:95
gloox::ConnectionHTTPProxy::cleanup
virtual void cleanup()
Definition connectionhttpproxy.cpp:110
gloox::ConnectionHTTPProxy::handleConnect
virtual void handleConnect(const ConnectionBase *connection)
Definition connectionhttpproxy.cpp:161
gloox::ConnectionHTTPProxy::handleReceivedData
virtual void handleReceivedData(const ConnectionBase *connection, const std::string &data)
Definition connectionhttpproxy.cpp:126
gloox::ConnectionHTTPProxy::setServer
void setServer(const std::string &host, int port=-1)
Definition connectionhttpproxy.h:131
gloox::ConnectionHTTPProxy::disconnect
virtual void disconnect()
Definition connectionhttpproxy.cpp:88
gloox::ConnectionHTTPProxy::newInstance
virtual ConnectionBase * newInstance() const
Definition connectionhttpproxy.cpp:63
gloox::ConnectionHTTPProxy::connect
virtual ConnectionError connect()
Definition connectionhttpproxy.cpp:77
gloox::ConnectionHTTPProxy::send
virtual bool send(const std::string &data)
Definition connectionhttpproxy.cpp:105
gloox::ConnectionHTTPProxy::setProxyAuth
void setProxyAuth(const std::string &user, const std::string &password)
Definition connectionhttpproxy.h:139
gloox::ConnectionHTTPProxy::ConnectionHTTPProxy
ConnectionHTTPProxy(ConnectionBase *connection, const LogSink &logInstance, const std::string &server, int port=-1)
Definition connectionhttpproxy.cpp:29
gloox::ConnectionHTTPProxy::receive
virtual ConnectionError receive()
Definition connectionhttpproxy.cpp:100
gloox::ConnectionHTTPProxy::getStatistics
virtual void getStatistics(long int &totalIn, long int &totalOut)
Definition connectionhttpproxy.cpp:118
gloox::LogSink
An implementation of log sink and source.
Definition logsink.h:39
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::ConnectionError
ConnectionError
Definition gloox.h:684