forked from RipcordSoftware/libhttpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest_stream.h
More file actions
59 lines (41 loc) · 1.33 KB
/
Copy pathrequest_stream.h
File metadata and controls
59 lines (41 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef RS_LIBHTTPSERVER_REQUEST_STREAM_H
#define RS_LIBHTTPSERVER_REQUEST_STREAM_H
#include <boost/noncopyable.hpp>
#include "stream.h"
#include "exceptions.h"
#include "socket.h"
#include "header_buffer.h"
namespace rs {
namespace httpserver {
class RequestStream final : public Stream, private boost::noncopyable {
public:
RequestStream(socket_ptr socket, HeaderBuffer& headerBuffer) :
socket_(socket), position_(0), length_(0), headerBuffer_(headerBuffer),
explictLength_(false) {}
virtual void Flush() override {};
virtual int Read(Stream::byte* buffer, int offset, int count, bool peek = false) override;
virtual int Write(const Stream::byte* buffer, int offset, int count) override {
throw InvalidStreamOperationException();
}
virtual long getPosition() override {
return position_;
}
virtual long getLength() override {
return length_;
}
void setLength(long length) {
if (length < position_) {
throw InvalidStreamOperationException();
}
length_ = length;
explictLength_ = true;
}
private:
socket_ptr socket_;
long position_;
long length_;
bool explictLength_;
HeaderBuffer& headerBuffer_;
};
}}
#endif /* RS_LIBHTTPSERVER_REQUEST_STREAM_H */