Panda3D
|
00001 // Filename: identityStreamBuf.h 00002 // Created by: drose (09Oct02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef IDENTITYSTREAMBUF_H 00016 #define IDENTITYSTREAMBUF_H 00017 00018 #include "pandabase.h" 00019 00020 // This module is not compiled if OpenSSL is not available. 00021 #ifdef HAVE_OPENSSL 00022 00023 #include "bioStreamPtr.h" 00024 #include "pointerTo.h" 00025 #include "socketStream.h" 00026 00027 class HTTPChannel; 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Class : IdentityStreamBuf 00031 // Description : The streambuf object that implements 00032 // IIdentityStream. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_PANDAEXPRESS IdentityStreamBuf : public streambuf { 00035 public: 00036 IdentityStreamBuf(); 00037 virtual ~IdentityStreamBuf(); 00038 00039 void open_read(BioStreamPtr *source, HTTPChannel *doc, 00040 bool has_content_length, size_t content_length); 00041 void close_read(); 00042 00043 INLINE bool is_closed() const; 00044 INLINE ISocketStream::ReadState get_read_state() const; 00045 00046 protected: 00047 virtual int underflow(); 00048 00049 private: 00050 size_t read_chars(char *start, size_t length); 00051 00052 PT(BioStreamPtr) _source; 00053 bool _has_content_length; 00054 size_t _bytes_remaining; 00055 bool _wanted_nonblocking; 00056 ISocketStream::ReadState _read_state; 00057 char *_buffer; 00058 00059 friend class IIdentityStream; 00060 }; 00061 00062 #include "identityStreamBuf.I" 00063 00064 #endif // HAVE_OPENSSL 00065 00066 #endif