1 | // |
---|---|
2 | // HTTPIOStream.h |
3 | // |
4 | // Library: Net |
5 | // Package: HTTP |
6 | // Module: HTTPIOStream |
7 | // |
8 | // Definition of the HTTPIOStream class. |
9 | // |
10 | // Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. |
11 | // and Contributors. |
12 | // |
13 | // SPDX-License-Identifier: BSL-1.0 |
14 | // |
15 | |
16 | |
17 | #ifndef Net_HTTPIOStream_INCLUDED |
18 | #define Net_HTTPIOStream_INCLUDED |
19 | |
20 | |
21 | #include "Poco/Net/Net.h" |
22 | #include "Poco/Net/HTTPResponse.h" |
23 | #include "Poco/UnbufferedStreamBuf.h" |
24 | |
25 | |
26 | namespace Poco { |
27 | namespace Net { |
28 | |
29 | |
30 | class HTTPClientSession; |
31 | |
32 | |
33 | class Net_API HTTPResponseStreamBuf: public Poco::UnbufferedStreamBuf |
34 | { |
35 | public: |
36 | HTTPResponseStreamBuf(std::istream& istr); |
37 | |
38 | ~HTTPResponseStreamBuf(); |
39 | |
40 | private: |
41 | int readFromDevice(); |
42 | |
43 | std::istream& _istr; |
44 | }; |
45 | |
46 | |
47 | inline int HTTPResponseStreamBuf::readFromDevice() |
48 | { |
49 | return _istr.get(); |
50 | } |
51 | |
52 | |
53 | class Net_API HTTPResponseIOS: public virtual std::ios |
54 | { |
55 | public: |
56 | HTTPResponseIOS(std::istream& istr); |
57 | |
58 | ~HTTPResponseIOS(); |
59 | |
60 | HTTPResponseStreamBuf* rdbuf(); |
61 | |
62 | protected: |
63 | HTTPResponseStreamBuf _buf; |
64 | }; |
65 | |
66 | |
67 | inline HTTPResponseStreamBuf* HTTPResponseIOS::rdbuf() |
68 | { |
69 | return &_buf; |
70 | } |
71 | |
72 | |
73 | class Net_API HTTPResponseStream: public HTTPResponseIOS, public std::istream |
74 | { |
75 | public: |
76 | HTTPResponseStream(std::istream& istr, HTTPClientSession* pSession); |
77 | |
78 | ~HTTPResponseStream(); |
79 | |
80 | private: |
81 | HTTPClientSession* _pSession; |
82 | }; |
83 | |
84 | |
85 | } } // namespace Poco::Net |
86 | |
87 | |
88 | #endif // Net_HTTPIOStream_INCLUDED |
89 |