memgraph/http/connection.hpp

33 lines
591 B
C++
Raw Normal View History

#pragma once
2016-03-14 04:51:04 +08:00
#include "io/network/tcp/stream.hpp"
#include "memory/literals.hpp"
2016-03-14 04:51:04 +08:00
namespace http
{
2016-03-14 04:51:04 +08:00
using namespace memory::literals;
2016-03-14 04:51:04 +08:00
template <class Req, class Res>
class Connection : public io::tcp::Stream
{
2016-03-14 04:51:04 +08:00
public:
struct Buffers
{
char headers[8_kB];
char body[64_kB];
static constexpr size_t size = sizeof headers + sizeof body;
};
2016-03-14 04:51:04 +08:00
Connection(io::Socket&& socket) : io::tcp::Stream(std::move(socket)),
response(this->socket) {}
// tcp stream reads into these buffers
Buffers buffers;
2016-03-14 04:51:04 +08:00
Req request;
Res response;
};
}