pica/request/request.h
2023-11-23 16:57:32 -03:00

44 lines
883 B
C++

#pragma once
#include <memory>
#include <stdexcept>
#include <string_view>
#include <fcgiapp.h>
#include <nlohmann/json.hpp>
#include "stream/ostream.h"
class Request {
public:
enum class State {
initial,
accepted,
responded
};
Request();
~Request();
Request(const Request& other) = delete;
Request(Request&& other) = delete;
Request& operator = (const Request& other) = delete;
Request& operator = (Request&& other) = delete;
bool wait(int socketDescriptor);
void terminate();
bool isGet() const;
OStream getOutputStream();
OStream getErrorStream();
std::string getPath(const std::string& serverName) const;
std::string getServerName() const;
void printEnvironment(std::ostream& out);
void printEnvironment(nlohmann::json& out);
private:
State state;
FCGX_Request raw;
};