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