2019-04-28 00:17:32 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-04-28 06:47:30 +00:00
|
|
|
#include <functional>
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
2019-04-28 00:17:32 +00:00
|
|
|
#include "buffer.h"
|
|
|
|
|
|
|
|
|
|
struct sockaddr_in6;
|
2019-04-28 06:47:30 +00:00
|
|
|
class FastCGIRequest;
|
2019-04-28 00:17:32 +00:00
|
|
|
|
|
|
|
|
class FastCGIConn {
|
|
|
|
|
public:
|
2019-04-28 06:47:30 +00:00
|
|
|
FastCGIConn(int sock, const sockaddr_in6& client_addr, const std::function<void(std::unique_ptr<FastCGIRequest>)>& callback);
|
2019-04-28 00:17:32 +00:00
|
|
|
~FastCGIConn();
|
|
|
|
|
|
|
|
|
|
void Serve();
|
|
|
|
|
|
2019-04-28 06:47:30 +00:00
|
|
|
void WriteBlock(uint8_t type, uint16_t request_id, const std::vector<iovec>& vecs);
|
|
|
|
|
void WriteOutput(uint16_t request_id, const std::vector<iovec>& vecs);
|
2019-04-28 07:02:59 +00:00
|
|
|
void WriteEnd(uint16_t request_id);
|
2019-04-28 06:47:30 +00:00
|
|
|
|
2019-04-28 00:17:32 +00:00
|
|
|
private:
|
|
|
|
|
void ParseBuf();
|
|
|
|
|
|
|
|
|
|
const int sock_;
|
2019-04-28 06:47:30 +00:00
|
|
|
std::function<void(std::unique_ptr<FastCGIRequest>)> callback_;
|
|
|
|
|
|
2019-04-28 00:17:32 +00:00
|
|
|
Buffer buf_;
|
2019-04-28 06:47:30 +00:00
|
|
|
|
|
|
|
|
std::unique_ptr<FastCGIRequest> request_;
|
2019-04-28 00:17:32 +00:00
|
|
|
};
|