Panda3D
 All Classes Functions Variables Enumerations
identityStreamBuf.h
1 // Filename: identityStreamBuf.h
2 // Created by: drose (09Oct02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef IDENTITYSTREAMBUF_H
16 #define IDENTITYSTREAMBUF_H
17 
18 #include "pandabase.h"
19 
20 // This module is not compiled if OpenSSL is not available.
21 #ifdef HAVE_OPENSSL
22 
23 #include "bioStreamPtr.h"
24 #include "pointerTo.h"
25 #include "socketStream.h"
26 
27 class HTTPChannel;
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : IdentityStreamBuf
31 // Description : The streambuf object that implements
32 // IIdentityStream.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_PANDAEXPRESS IdentityStreamBuf : public streambuf {
35 public:
36  IdentityStreamBuf();
37  virtual ~IdentityStreamBuf();
38 
39  void open_read(BioStreamPtr *source, HTTPChannel *doc,
40  bool has_content_length, size_t content_length);
41  void close_read();
42 
43  INLINE bool is_closed() const;
44  INLINE ISocketStream::ReadState get_read_state() const;
45 
46 protected:
47  virtual int underflow();
48 
49 private:
50  size_t read_chars(char *start, size_t length);
51 
52  PT(BioStreamPtr) _source;
53  bool _has_content_length;
54  size_t _bytes_remaining;
55  bool _wanted_nonblocking;
56  ISocketStream::ReadState _read_state;
57  char *_buffer;
58 
59  friend class IIdentityStream;
60 };
61 
62 #include "identityStreamBuf.I"
63 
64 #endif // HAVE_OPENSSL
65 
66 #endif