pica/request/request.h

47 lines
991 B
C
Raw Normal View History

// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
2023-11-21 22:19:08 +00:00
#pragma once
#include <memory>
#include <stdexcept>
#include <string_view>
#include <fcgiapp.h>
2023-11-23 19:57:32 +00:00
#include <nlohmann/json.hpp>
2023-11-21 22:19:08 +00:00
#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();
2023-11-23 19:57:32 +00:00
std::string getPath(const std::string& serverName) const;
2023-11-21 22:19:08 +00:00
std::string getServerName() const;
void printEnvironment(std::ostream& out);
2023-11-23 19:57:32 +00:00
void printEnvironment(nlohmann::json& out);
2023-11-21 22:19:08 +00:00
private:
State state;
FCGX_Request raw;
};