aboutsummaryrefslogtreecommitdiff
path: root/src/RequestResponse.hpp
blob: d3d3551b1318ba1177ed2837c8d660648a2f01b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef REQUEST_RESPONSE_H
#define REQUEST_RESPONSE_H 1

#include <event2/http.h>
#include <event2/keyvalq_struct.h>

#include <string>

class RequestResponse
{
public:
    explicit RequestResponse(char const * const uri_path, struct evhttp_request * const req);
    ~RequestResponse();

    char const * GetUriPath() const
    {
        return m_UriPath;
    }

    void UseInputHeader();
    void UseOutputHeader();
    bool UseUri();

    bool AddOutputHeaderByRef(std::string const & key, std::string const & value);
    bool AddOutputHeader(std::string const key, std::string const value);

    bool RemoveOutputHeaderByRef(std::string const & key);
    bool RemoveOutputHeader(std::string const key);

    bool GetInputHeaderByRef(std::string const & key, std::string & value);
    bool GetInputHeader(std::string const key, std::string value);

    bool GetQueryValue(std::string & key, std::string & value);
    bool GetQueryValue(std::string const key, std::string & value);

    bool QueryValueEquals(std::string & key, std::string value);
    bool QueryValueEquals(std::string const key, std::string value);

private:
    char const * const m_UriPath;
    struct evhttp_request * const m_Request;
    struct evkeyvalq * m_InputHeader;
    struct evkeyvalq * m_OutputHeader;
    struct evkeyvalq m_Query = {};
};

#endif