Remote Call Framework 3.2
HttpConnectFilter.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2020, Delta V Software. All rights reserved.
6 // http://www.deltavsoft.com
7 //
8 // RCF is distributed under dual licenses - closed source or GPL.
9 // Consult your particular license for conditions of use.
10 //
11 // If you have not purchased a commercial license, you are using RCF
12 // under GPL terms.
13 //
14 // Version: 3.2
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18 
19 #ifndef INCLUDE_RCF_HTTPCONNECTFILTER_HPP
20 #define INCLUDE_RCF_HTTPCONNECTFILTER_HPP
21 
22 #include <memory>
23 #include <memory>
24 
25 #include <RCF/Filter.hpp>
26 #include <RCF/HttpFrameFilter.hpp>
27 
28 namespace RCF {
29 
30  class NtlmWrapper;
31 
32  class ByteBuffer;
33 
34  class HttpConnectFilter : public Filter
35  {
36  public:
37 
38  HttpConnectFilter();
39  HttpConnectFilter(const std::string serverAddr, int serverPort);
40  ~HttpConnectFilter();
41 
42  void resetState();
43 
44  void read(
45  const ByteBuffer &byteBuffer,
46  std::size_t bytesRequested);
47 
48  void write(const std::vector<ByteBuffer> &byteBuffers);
49 
50  void onReadCompleted(const ByteBuffer &byteBuffer);
51 
52  void onWriteCompleted(std::size_t bytesTransferred);
53 
54  int getFilterId() const;
55 
56  enum AuthType
57  {
58  AuthType_None,
59  AuthType_Basic,
60  AuthType_Digest,
61  AuthType_Ntlm,
62  AuthType_Negotiate
63  };
64 
65  private:
66 
67  void sendProxyRequest();
68  void tryNextAuthType();
69 
70  void doNtlmHandshake();
71  void doProxyAuthRetry();
72 
73  std::string mServerAddr;
74  int mServerPort;
75 
76  bool mPassThrough;
77 
78  std::vector<ByteBuffer> mOrigWriteBuffers;
79 
80  std::string mHttpProxyRequest;
81  std::string mHttpProxyResponse;
82 
83  HttpMessage mHttpMessage;
84 
85  std::size_t mWritePos;
86  std::size_t mReadPos;
87 
88  std::vector<char> mReadVector;
89 
90  // List of (Auth type, realm) returned by the proxy.
91  std::vector< std::pair<AuthType, std::string> >
92  mProxyAuthTypes;
93 
94  std::size_t mCurrentAuthType;
95 
96  std::unique_ptr<NtlmWrapper> mNtlmWrapper;
97  };
98 
99 } // namespace RCF
100 
101 #endif // ! INCLUDE_RCF_HTTPCONNECTFILTER_HPP
Definition: AmiIoHandler.hpp:24