forked from RipcordSoftware/libhttpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchunked_request_stream.h
More file actions
47 lines (31 loc) · 1.19 KB
/
Copy pathchunked_request_stream.h
File metadata and controls
47 lines (31 loc) · 1.19 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
#ifndef RS_LIBHTTPSERVER_CHUNKED_REQUEST_STREAM_H
#define RS_LIBHTTPSERVER_CHUNKED_REQUEST_STREAM_H
#include <boost/noncopyable.hpp>
#include "stream.h"
#include "exceptions.h"
#include "config.h"
namespace rs {
namespace httpserver {
class ChunkedRequestStream final : public Stream, private boost::noncopyable {
public:
ChunkedRequestStream(Stream& stream) : stream_(stream), position_(0), length_(0),
chunkLength_(0), chunkPosition_(0) {}
virtual void Flush() override {}
virtual int Read(byte* buffer, int offset, int count, bool peek = false) override;
virtual int Write(const byte* buffer, int offset, int count) override {
throw InvalidStreamOperationException();
}
virtual long getPosition() override { return position_; }
virtual long getLength() override { return length_; }
private:
void ReadHeader();
static bool GetChunkSize(const byte* buffer, const int bufferLength, int& chunkLength, int& headerLength);
Stream& stream_;
long position_;
long length_;
int chunkLength_;
int chunkPosition_;
static const byte endOfLine_[2];
};
}}
#endif /* RS_LIBHTTPSERVER_CHUNKED_REQUEST_STREAM_H */