Files
firecgi/connection.h

36 lines
701 B
C
Raw Permalink Normal View History

2019-05-04 23:21:33 -07:00
#pragma once
#include <sys/uio.h>
2019-05-18 12:15:11 -07:00
#include <functional>
2019-05-04 23:21:33 -07:00
#include <unordered_map>
#include <unordered_set>
2019-05-04 23:42:03 -07:00
#include "firebuf/stream_buffer.h"
2019-05-04 23:21:33 -07:00
#include "request.h"
namespace firecgi {
class Connection {
2019-05-18 12:15:11 -07:00
public:
Connection(int sock, const sockaddr_in6& client_addr,
const std::function<void(Request*)>& callback,
int max_request_len);
~Connection();
2019-05-04 23:21:33 -07:00
2019-05-18 12:15:11 -07:00
[[nodiscard]] int Read();
[[nodiscard]] bool Write(const std::vector<iovec>& vecs);
2019-05-18 12:15:11 -07:00
[[nodiscard]] uint64_t Requests() const;
2019-05-04 23:21:33 -07:00
2019-05-18 12:15:11 -07:00
private:
const int sock_;
const std::function<void(Request*)>& callback_;
firebuf::StreamBuffer buf_;
Request request_;
2019-05-04 23:21:33 -07:00
2019-05-18 12:15:11 -07:00
uint64_t requests_ = 0;
2019-05-04 23:21:33 -07:00
};
2019-05-18 12:15:11 -07:00
} // namespace firecgi