Files
firecgi/request.h

49 lines
945 B
C
Raw Normal View History

2019-05-04 23:42:03 -07:00
#pragma once
2019-05-09 20:24:59 -07:00
#include <mutex>
2019-05-04 23:42:03 -07:00
#include <unordered_map>
#include "firebuf/buffer.h"
#include "parse.h"
namespace firecgi {
class Connection;
class Request {
public:
Request(Connection *conn);
void NewRequest(uint16_t request_id);
2019-05-04 23:42:03 -07:00
uint16_t RequestId();
void AddParam(const std::string_view& key, const std::string_view& value);
void SetBody(const std::string_view& in);
2019-05-04 23:42:03 -07:00
2019-05-09 19:49:05 -07:00
const std::string_view& GetParam(const std::string& key);
const std::string_view& GetBody();
2019-05-04 23:42:03 -07:00
void WriteHeader(const std::string_view& name, const std::string_view& value);
void WriteBody(const std::string_view& body);
[[nodiscard]] bool Flush();
bool End();
private:
Header OutputHeader();
iovec OutputVec();
Connection *conn_;
uint16_t request_id_ = 0;
2019-05-04 23:42:03 -07:00
2019-05-09 19:49:05 -07:00
std::unordered_map<std::string_view, std::string_view> params_;
std::string_view body_;
2019-05-04 23:42:03 -07:00
firebuf::Buffer out_buf_;
bool body_written_;
2019-05-09 20:24:59 -07:00
std::mutex output_mu_;
2019-05-04 23:42:03 -07:00
};
} // namespace firecgi