46 lines
1016 B
C++
46 lines
1016 B
C++
#pragma once
|
|
#include <map>
|
|
#include <string>
|
|
|
|
namespace webcxx {
|
|
enum RequestType { GET = 1 << 0, POST = 1 << 1, PUT = 1 << 2, DELETE = 1 << 3 };
|
|
|
|
class App;
|
|
class Map;
|
|
|
|
class Request {
|
|
public:
|
|
RequestType method() { return m_method; }
|
|
std::string ip() { return m_ip; }
|
|
|
|
Map headers() const;
|
|
|
|
Map args() const;
|
|
|
|
std::string path() const { return m_path; }
|
|
std::string content() const { return m_content; }
|
|
|
|
private:
|
|
explicit Request(int fd);
|
|
|
|
bool is_bad_request() { return m_bad_request; };
|
|
|
|
RequestType m_method;
|
|
std::string m_path;
|
|
std::string m_real_path;
|
|
std::string m_content;
|
|
std::map<std::string, std::string> m_headers;
|
|
bool m_bad_request = false;
|
|
std::string m_ip;
|
|
|
|
std::map<std::string, std::string> m_args;
|
|
|
|
std::pair<std::string, std::string> split_header(std::string input,
|
|
std::string delim);
|
|
void decode_http_header(std::string header);
|
|
|
|
void log(int status_code);
|
|
|
|
friend class App;
|
|
};
|
|
} // namespace webcxx
|