PageRenderTime 527ms CodeModel.GetById 138ms app.highlight 3ms RepoModel.GetById 244ms app.codeStats 1ms

/mordor/http/chunked.h

http://github.com/mozy/mordor
C Header | 47 lines | 36 code | 10 blank | 1 comment | 0 complexity | a0d9481ad73954e4b96aaad6c4aa7406 MD5 | raw file
 1#ifndef __MORDOR_HTTP_CHUNKED_H__
 2#define __MORDOR_HTTP_CHUNKED_H__
 3// Copyright (c) 2009 - Mozy, Inc.
 4
 5#include "mordor/exception.h"
 6#include "mordor/streams/filter.h"
 7
 8namespace Mordor {
 9namespace HTTP {
10
11struct InvalidChunkException : virtual StreamException
12{
13public:
14    enum Type
15    {
16        HEADER,
17        FOOTER
18    };
19    InvalidChunkException(const std::string &line, Type type);
20    ~InvalidChunkException() throw() {}
21
22    const std::string &line() const { return m_line; }
23    Type type() const { return m_type; }
24
25private:
26    std::string m_line;
27    Type m_type;
28};
29
30class ChunkedStream : public MutatingFilterStream
31{
32public:
33    ChunkedStream(Stream::ptr parent, bool own = true);
34
35    void close(CloseType type = BOTH);
36    using MutatingFilterStream::read;
37    size_t read(Buffer &b, size_t len);
38    using MutatingFilterStream::write;
39    size_t write(const Buffer &b, size_t len);
40
41private:
42    unsigned long long m_nextChunk;
43};
44
45}}
46
47#endif