00001 // $Id: HTTP_StreamPolicy.h 91118 2010-07-17 10:29:57Z mcorino $ 00002 00003 /** 00004 * @file HTTP_StreamPolicy.h 00005 * 00006 * @author Martin Corino <mcorino@remedy.nl> 00007 */ 00008 00009 #ifndef ACE_HTTP_STREAM_POLICY_H 00010 #define ACE_HTTP_STREAM_POLICY_H 00011 00012 #include /**/ "ace/pre.h" 00013 00014 #include "ace/INet/INet_Export.h" 00015 #include "ace/INet/HTTP_StreamPolicyBase.h" 00016 #include "ace/INet/HTTP_IOStream.h" 00017 #include "ace/INet/String_IOStream.h" 00018 00019 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00020 00021 namespace ACE 00022 { 00023 namespace HTTP 00024 { 00025 /** 00026 * @class ACE_HTTP_FixedLengthStreamPolicy 00027 * 00028 * @brief Implements stream policy for fixed length data stream 00029 * in HTTP response or request. 00030 * 00031 */ 00032 template <class STREAM_BUFFER> 00033 class FixedLengthStreamPolicyBase 00034 : public StreamPolicyBase<STREAM_BUFFER> 00035 { 00036 public: 00037 typedef typename STREAM_BUFFER::char_type char_type; 00038 00039 FixedLengthStreamPolicyBase (std::streamsize length); 00040 virtual ~FixedLengthStreamPolicyBase (); 00041 00042 protected: 00043 virtual int read_from_stream (char_type* buffer, std::streamsize length); 00044 00045 virtual int write_to_stream (const char_type* buffer, std::streamsize length); 00046 00047 private: 00048 std::streamsize length_; 00049 std::streamsize count_; 00050 }; 00051 00052 typedef FixedLengthStreamPolicyBase<StreamBuffer> FixedLengthStreamPolicy; 00053 00054 /** 00055 * @class ACE_HTTP_ChunkedTransferStreamPolicy 00056 * 00057 * @brief Implements stream policy for chunked data streams 00058 * in HTTP response or request. 00059 * 00060 */ 00061 template <class STREAM_BUFFER> 00062 class ChunkedTransferStreamPolicyBase 00063 : public StreamPolicyBase<STREAM_BUFFER> 00064 { 00065 public: 00066 typedef typename STREAM_BUFFER::char_type char_type; 00067 typedef ACE::IOS::String_OStreamBase<char_type> buffer_type; 00068 00069 ChunkedTransferStreamPolicyBase (); 00070 virtual ~ChunkedTransferStreamPolicyBase (); 00071 00072 protected: 00073 virtual int read_from_stream (char_type* buffer, std::streamsize length); 00074 00075 virtual int write_to_stream (const char_type* buffer, std::streamsize length); 00076 00077 int getc (); 00078 00079 private: 00080 std::streamsize chunk_cnt_; 00081 buffer_type chunk_; 00082 }; 00083 00084 typedef ChunkedTransferStreamPolicyBase<StreamBuffer> ChunkedTransferStreamPolicy; 00085 00086 } 00087 } 00088 00089 ACE_END_VERSIONED_NAMESPACE_DECL 00090 00091 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) 00092 #include "ace/INet/HTTP_StreamPolicy.cpp" 00093 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ 00094 00095 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) 00096 #pragma implementation ("HTTP_StreamPolicy.cpp") 00097 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ 00098 00099 #include /**/ "ace/post.h" 00100 #endif /* ACE_HTTP_STREAM_POLICY_H */