2019-04-28 06:47:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
2019-04-28 18:19:32 +00:00
|
|
|
#include "buffer.h"
|
2019-04-28 18:51:56 +00:00
|
|
|
#include "fastcgi_parse.h"
|
2019-04-28 18:19:32 +00:00
|
|
|
|
2019-04-28 06:47:30 +00:00
|
|
|
class FastCGIConn;
|
|
|
|
|
|
|
|
|
|
class FastCGIRequest {
|
|
|
|
|
public:
|
|
|
|
|
FastCGIRequest(uint16_t request_id, FastCGIConn *conn);
|
|
|
|
|
|
2019-04-28 20:40:00 +00:00
|
|
|
uint16_t RequestId();
|
|
|
|
|
|
2019-04-28 06:47:30 +00:00
|
|
|
void AddParam(const std::string_view& key, const std::string_view& value);
|
|
|
|
|
void AddIn(const std::string_view& in);
|
|
|
|
|
|
|
|
|
|
const std::string& GetParam(const std::string& key);
|
|
|
|
|
|
2019-04-28 18:19:32 +00:00
|
|
|
void WriteHeader(const std::string_view& name, const std::string_view& value);
|
|
|
|
|
void WriteBody(const std::string_view& body);
|
|
|
|
|
void Flush();
|
|
|
|
|
void End();
|
2019-04-28 06:47:30 +00:00
|
|
|
|
|
|
|
|
private:
|
2019-04-28 18:51:56 +00:00
|
|
|
FastCGIHeader OutputHeader();
|
|
|
|
|
iovec OutputVec();
|
|
|
|
|
|
2019-04-28 06:47:30 +00:00
|
|
|
const uint16_t request_id_;
|
|
|
|
|
FastCGIConn *conn_;
|
|
|
|
|
|
|
|
|
|
std::unordered_map<std::string, std::string> params_;
|
|
|
|
|
std::string in_;
|
2019-04-28 18:19:32 +00:00
|
|
|
|
|
|
|
|
Buffer out_buf_;
|
2019-04-28 18:51:56 +00:00
|
|
|
bool body_written_ = false;
|
2019-04-28 06:47:30 +00:00
|
|
|
};
|