00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CHUNKEDSTREAMBUF_H
00016 #define CHUNKEDSTREAMBUF_H
00017
00018 #include "pandabase.h"
00019
00020
00021 #ifdef HAVE_OPENSSL
00022
00023 #include "httpChannel.h"
00024 #include "bioStreamPtr.h"
00025 #include "pointerTo.h"
00026
00027
00028
00029
00030
00031
00032
00033 class ChunkedStreamBuf : public streambuf {
00034 public:
00035 ChunkedStreamBuf();
00036 virtual ~ChunkedStreamBuf();
00037
00038 void open_read(BioStreamPtr *source, HTTPChannel *doc);
00039 void close_read();
00040
00041 INLINE bool is_closed() const;
00042 INLINE ISocketStream::ReadState get_read_state() const;
00043
00044 protected:
00045 virtual int underflow();
00046
00047 private:
00048 size_t read_chars(char *start, size_t length);
00049 bool http_getline(string &str);
00050
00051 PT(BioStreamPtr) _source;
00052 size_t _chunk_remaining;
00053 bool _done;
00054 bool _wanted_nonblocking;
00055 string _working_getline;
00056 ISocketStream::ReadState _read_state;
00057
00058 PT(HTTPChannel) _doc;
00059 int _read_index;
00060 char *_buffer;
00061
00062 friend class IChunkedStream;
00063 };
00064
00065 #include "chunkedStreamBuf.I"
00066
00067 #endif // HAVE_OPENSSL
00068
00069 #endif