aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/IO/HTTPChunkedReadBuffer.h
blob: 68d90e470fa53520ec187a7d7bc10d60f92b1116 (plain) (blame)
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
#pragma once

#include <IO/BufferWithOwnMemory.h>
#include <IO/ReadBuffer.h>

namespace DB
{

/// Reads data with HTTP Chunked Transfer Encoding.
class HTTPChunkedReadBuffer : public BufferWithOwnMemory<ReadBuffer>
{
public:
    explicit HTTPChunkedReadBuffer(std::unique_ptr<ReadBuffer> in_, size_t max_chunk_size_)
        : max_chunk_size(max_chunk_size_), in(std::move(in_))
    {}

private:
    const size_t max_chunk_size;
    std::unique_ptr<ReadBuffer> in;

    size_t readChunkHeader();
    void readChunkFooter();

    bool nextImpl() override;
};

}