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