Panda3D
chunkedStreamBuf.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 chunkedStreamBuf.h
10  * @author drose
11  * @date 2002-09-25
12  */
13 
14 #ifndef CHUNKEDSTREAMBUF_H
15 #define CHUNKEDSTREAMBUF_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 "httpChannel.h"
23 #include "bioStreamPtr.h"
24 #include "pointerTo.h"
25 
26 /**
27  * The streambuf object that implements IChunkedStream.
28  */
29 class ChunkedStreamBuf : public std::streambuf {
30  // No need to export from DLL.
31 public:
32  ChunkedStreamBuf();
33  virtual ~ChunkedStreamBuf();
34 
35  void open_read(BioStreamPtr *source, HTTPChannel *doc);
36  void close_read();
37 
38  INLINE bool is_closed() const;
39  INLINE ISocketStream::ReadState get_read_state() const;
40 
41 protected:
42  virtual int underflow();
43 
44 private:
45  size_t read_chars(char *start, size_t length);
46  bool http_getline(std::string &str);
47 
48  PT(BioStreamPtr) _source;
49  size_t _chunk_remaining;
50  bool _done;
51  bool _wanted_nonblocking;
52  std::string _working_getline;
53  ISocketStream::ReadState _read_state;
54 
55  PT(HTTPChannel) _doc;
56  int _read_index;
57  char *_buffer;
58 
59  friend class IChunkedStream;
60 };
61 
62 #include "chunkedStreamBuf.I"
63 
64 #endif // HAVE_OPENSSL
65 
66 #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.