gloox
1.0.28
|
#include <connectionhttpproxy.h>
Public Member Functions | |
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 () |
virtual ConnectionError | connect () |
virtual ConnectionError | recv (int timeout=-1) |
virtual bool | send (const std::string &data) |
virtual ConnectionError | receive () |
virtual void | disconnect () |
virtual void | cleanup () |
virtual void | getStatistics (long int &totalIn, long int &totalOut) |
virtual void | handleReceivedData (const ConnectionBase *connection, const std::string &data) |
virtual void | handleConnect (const ConnectionBase *connection) |
virtual void | handleDisconnect (const ConnectionBase *connection, ConnectionError reason) |
virtual ConnectionBase * | newInstance () const |
void | setServer (const std::string &host, int port=-1) |
void | setProxyAuth (const std::string &user, const std::string &password) |
void | setConnectionImpl (ConnectionBase *connection) |
void | setHTTP11 (bool http11) |
Public Member Functions inherited from ConnectionBase | |
ConnectionBase (ConnectionDataHandler *cdh) | |
virtual | ~ConnectionBase () |
ConnectionState | state () const |
void | registerConnectionDataHandler (ConnectionDataHandler *cdh) |
void | setServer (const std::string &server, int port=-1) |
const std::string & | server () const |
int | port () const |
virtual int | localPort () const |
virtual const std::string | localInterface () const |
Public Member Functions inherited from ConnectionDataHandler | |
virtual | ~ConnectionDataHandler () |
Additional Inherited Members | |
Protected Attributes inherited from ConnectionBase | |
ConnectionDataHandler * | m_handler |
ConnectionState | m_state |
std::string | m_server |
int | m_port |
This is an implementation of a simple HTTP Proxying connection.
Usage:
Make sure to pass the proxy host/port to the transport connection (ConnectionTCPClient in this case), and the XMPP host/port to the proxy connection.
ConnectionHTTPProxy uses the CONNECT method to pass through the proxy. If your proxy does not allow this kind of connections, or if it kills connections after some time, you may want to use ConnectionBOSH instead or in addition.
The reason why ConnectionHTTPProxy doesn't manage its own ConnectionTCPClient is that it allows it to be used with other transports (like IPv6 or chained SOCKS5/HTTP proxies).
Definition at line 53 of file connectionhttpproxy.h.
ConnectionHTTPProxy | ( | ConnectionBase * | connection, |
const LogSink & | logInstance, | ||
const std::string & | server, | ||
int | port = -1 |
||
) |
Constructs a new ConnectionHTTPProxy object.
connection | A transport connection. It should be configured to connect to the proxy host and port, not to the XMPP host. ConnectionHTTPProxy will own the transport connection and delete it in its destructor. |
logInstance | The log target. Obtain it from ClientBase::logInstance(). |
server | A server to connect to. This is the XMPP server's address, not the proxy. |
port | The port to connect to. This is the XMPP server's port, not the proxy's. The default of -1 means that SRV records will be used to find out about the actual host:port. |
Definition at line 29 of file connectionhttpproxy.cpp.
ConnectionHTTPProxy | ( | ConnectionDataHandler * | cdh, |
ConnectionBase * | connection, | ||
const LogSink & | logInstance, | ||
const std::string & | server, | ||
int | port = -1 |
||
) |
Constructs a new ConnectionHTTPProxy object.
cdh | An ConnectionDataHandler-derived object that will handle incoming data. |
connection | A transport connection. It should be configured to connect to the proxy host and port, not to the XMPP host. ConnectionHTTPProxy will own the transport connection and delete it in its destructor. |
logInstance | The log target. Obtain it from ClientBase::logInstance(). |
server | A server to connect to. This is the XMPP server's address, not the proxy. |
port | The port to connect to. This is the XMPP server's port, not the proxy's. The default of -1 means that SRV records will be used to find out about the actual host:port. |
Definition at line 43 of file connectionhttpproxy.cpp.
|
virtual |
Virtual destructor
Definition at line 58 of file connectionhttpproxy.cpp.
|
virtual |
This function is called after a disconnect to clean up internal state. It is also called by ConnectionBase's destructor.
Reimplemented from ConnectionBase.
Definition at line 110 of file connectionhttpproxy.cpp.
|
virtual |
Used to initiate the connection.
Implements ConnectionBase.
Definition at line 77 of file connectionhttpproxy.cpp.
|
virtual |
Disconnects an established connection. NOOP if no active connection exists.
Implements ConnectionBase.
Definition at line 88 of file connectionhttpproxy.cpp.
|
virtual |
Returns current connection statistics.
totalIn | The total number of bytes received. |
totalOut | The total number of bytes sent. |
Implements ConnectionBase.
Definition at line 118 of file connectionhttpproxy.cpp.
|
virtual |
This function is called when e.g. the raw TCP connection was established.
connection | The connection. |
Implements ConnectionDataHandler.
Definition at line 161 of file connectionhttpproxy.cpp.
|
virtual |
This connection is called when e.g. the raw TCP connection was closed.
connection | The connection. |
reason | The reason for the disconnect. |
Implements ConnectionDataHandler.
Definition at line 205 of file connectionhttpproxy.cpp.
|
virtual |
This function is called for received from the underlying transport.
connection | The connection that received the data. |
data | The data received. |
Implements ConnectionDataHandler.
Definition at line 126 of file connectionhttpproxy.cpp.
|
virtual |
This function returns a new instance of the current ConnectionBase-derived object. The idea is to be able to 'clone' ConnectionBase-derived objects without knowing of what type they are exactly.
Implements ConnectionBase.
Definition at line 63 of file connectionhttpproxy.cpp.
|
virtual |
Use this function to put the connection into 'receive mode', i.e. this function returns only when the connection is terminated.
Implements ConnectionBase.
Definition at line 100 of file connectionhttpproxy.cpp.
|
virtual |
Use this periodically to receive data from the socket.
timeout | The timeout to use for select in microseconds. Default of -1 means blocking. |
Implements ConnectionBase.
Definition at line 95 of file connectionhttpproxy.cpp.
|
virtual |
Use this function to send a string of data over the wire. The function returns only after all data has been sent.
data | The data to send. |
Implements ConnectionBase.
Definition at line 105 of file connectionhttpproxy.cpp.
void setConnectionImpl | ( | ConnectionBase * | connection | ) |
Sets the underlying transport connection. A possibly existing connection will be deleted.
connection | The ConnectionBase to replace the current connection, if any. |
Definition at line 69 of file connectionhttpproxy.cpp.
|
inline |
Switches usage of HTTP/1.1 on or off.
http11 | Set this to true to connect through a HTTP/1.1-only proxy, or false to use HTTP/1.0. Defaults to HTTP/1.0 which should work with 99.9% of proxies. |
Definition at line 153 of file connectionhttpproxy.h.
|
inline |
Sets proxy authorization credentials.
user | The user name to use for proxy authorization. |
password | The password to use for proxy authorization. |
Definition at line 139 of file connectionhttpproxy.h.
|
inline |
Sets the XMPP server to proxy to.
host | The XMPP server hostname (IP address). |
port | The XMPP server port. The default of -1 means that SRV records will be used to find out about the actual host:port. |
Definition at line 131 of file connectionhttpproxy.h.