Panda3D
identityStream.h
1 // Filename: identityStream.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 IDENTITYSTREAM_H
16 #define IDENTITYSTREAM_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 "socketStream.h"
24 #include "identityStreamBuf.h"
25 
26 class HTTPChannel;
27 class BioStreamPtr;
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : IIdentityStream
31 // Description : An input stream object that reads data from a source
32 // istream, but automatically decodes the "identity"
33 // transfer-coding specified by an HTTP server.
34 //
35 // In practice, this just means it reads from the sub
36 // stream (like a SubStreamBuf) up to but not past the
37 // specified content-length. (If the content-length was
38 // unspecified, this class cannot be used.) It also
39 // updates the HTTPChannel when the stream is
40 // completely read.
41 ////////////////////////////////////////////////////////////////////
42 // No need to export from DLL.
43 class IIdentityStream : public ISocketStream {
44 public:
45  INLINE IIdentityStream();
46  INLINE IIdentityStream(BioStreamPtr *source, HTTPChannel *doc,
47  bool has_content_length, size_t content_length);
48 
49  INLINE IIdentityStream &open(BioStreamPtr *source, HTTPChannel *doc,
50  bool has_content_length, size_t content_length);
51  virtual ~IIdentityStream();
52 
53  virtual bool is_closed();
54  virtual void close();
55  virtual ReadState get_read_state();
56 
57 private:
58  IdentityStreamBuf _buf;
59 };
60 
61 #include "identityStream.I"
62 
63 #endif // HAVE_OPENSSL
64 
65 #endif
66 
67