RCFProto
 All Classes Functions Typedefs
HttpFrameFilter.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2013, 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: 2.0
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18 
19 #ifndef INCLUDE_RCF_HTTPFRAMEFILTER_HPP
20 #define INCLUDE_RCF_HTTPFRAMEFILTER_HPP
21 
22 #include <map>
23 
24 #include <boost/shared_ptr.hpp>
25 
26 #include <RCF/Filter.hpp>
27 #include <RCF/ByteBuffer.hpp>
28 
29 namespace RCF {
30 
31  class HttpFrameFilter : public Filter
32  {
33  public:
34 
35  HttpFrameFilter();
36  HttpFrameFilter(const std::string serverAddr, int serverPort);
37 
38  void resetState();
39 
40  void read(
41  const ByteBuffer &byteBuffer,
42  std::size_t bytesRequested);
43 
44  void write(const std::vector<ByteBuffer> &byteBuffers);
45 
46  void onReadCompleted(const ByteBuffer &byteBuffer);
47 
48  void onWriteCompleted(std::size_t bytesTransferred);
49 
50  int getFilterId() const;
51 
52  virtual std::size_t getFrameSize();
53 
54  private:
55 
56  std::string mServerAddr;
57  int mServerPort;
58 
59  std::vector<ByteBuffer> mWriteBuffers;
60  std::size_t mWritePos;
61 
62  ByteBuffer mOrigReadBuffer;
63  std::size_t mOrigBytesRequested;
64 
65  boost::shared_ptr< std::vector<char> > mReadVectorPtr;
66  std::size_t mBytesReceived;
67  std::size_t mReadPos;
68 
69  std::size_t mHeaderLen;
70  std::size_t mContentLen;
71 
72  std::string mRequestLine;
73  std::string mResponseLine;
74  std::map<std::string, std::string> mHeaders;
75  };
76 
77 } // namespace RCF
78 
79 #endif // ! INCLUDE_RCF_HTTPFRAMEFILTER_HPP