ClickHouse/src/IO/HTTPChunkedReadBuffer.h
2022-08-18 14:30:52 +02:00

28 lines
561 B
C++

#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;
};
}