gloox  1.0.20
connectionhttpproxy.h
1 /*
2  Copyright (c) 2004-2017 by Jakob Schröter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #ifndef CONNECTIONHTTPPROXY_H__
15 #define CONNECTIONHTTPPROXY_H__
16 
17 #include "gloox.h"
18 #include "connectionbase.h"
19 #include "logsink.h"
20 
21 #include <string>
22 
23 namespace gloox
24 {
25 
53  class GLOOX_API ConnectionHTTPProxy : public ConnectionBase, public ConnectionDataHandler
54  {
55  public:
69  ConnectionHTTPProxy( ConnectionBase* connection, const LogSink& logInstance,
70  const std::string& server, int port = -1 );
71 
84  const LogSink& logInstance,
85  const std::string& server, int port = -1 );
86 
90  virtual ~ConnectionHTTPProxy();
91 
92  // reimplemented from ConnectionBase
93  virtual ConnectionError connect();
94 
95  // reimplemented from ConnectionBase
96  virtual ConnectionError recv( int timeout = -1 );
97 
98  // reimplemented from ConnectionBase
99  virtual bool send( const std::string& data );
100 
101  // reimplemented from ConnectionBase
102  virtual ConnectionError receive();
103 
104  // reimplemented from ConnectionBase
105  virtual void disconnect();
106 
107  // reimplemented from ConnectionBase
108  virtual void cleanup();
109 
110  // reimplemented from ConnectionBase
111  virtual void getStatistics( long int &totalIn, long int &totalOut );
112 
113  // reimplemented from ConnectionDataHandler
114  virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data );
115 
116  // reimplemented from ConnectionDataHandler
117  virtual void handleConnect( const ConnectionBase* connection );
118 
119  // reimplemented from ConnectionDataHandler
120  virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason );
121 
122  // reimplemented from ConnectionDataHandler
123  virtual ConnectionBase* newInstance() const;
124 
131  void setServer( const std::string& host, int port = -1 )
132  { m_server = host; m_port = port; }
133 
139  void setProxyAuth( const std::string& user, const std::string& password )
140  { m_proxyUser = user; m_proxyPwd = password; }
141 
146  void setConnectionImpl( ConnectionBase* connection );
147 
153  void setHTTP11( bool http11 ) { m_http11 = http11; }
154 
155  private:
156  ConnectionHTTPProxy &operator=( const ConnectionHTTPProxy& );
157 
158  ConnectionBase* m_connection;
159  const LogSink& m_logInstance;
160 
161  std::string m_proxyUser;
162  std::string m_proxyPwd;
163  std::string m_proxyHandshakeBuffer;
164 
165  bool m_http11;
166 
167  };
168 
169 }
170 
171 #endif // CONNECTIONHTTPPROXY_H__
An abstract base class for a connection.
ConnectionError
Definition: gloox.h:683
This is an abstract base class to receive events from a ConnectionBase-derived object.
The namespace for the gloox library.
Definition: adhoc.cpp:27
This is an implementation of a simple HTTP Proxying connection.
An implementation of log sink and source.
Definition: logsink.h:38
void setProxyAuth(const std::string &user, const std::string &password)
void setServer(const std::string &host, int port=-1)