32 lines
693 B
C++
32 lines
693 B
C++
#pragma once
|
|
|
|
#include "http_common.hpp"
|
|
#include "cookie.hpp"
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
using std::string_view;
|
|
using std::string;
|
|
|
|
struct HttpRequest {
|
|
HttpMethod method = HttpMethod::UNKNOWN;
|
|
string_view path;
|
|
string_view query;
|
|
string_view version;
|
|
string_view body;
|
|
std::unordered_map<string_view, string_view> headers;
|
|
std::unordered_map<string, string> params; // URL parameters
|
|
std::vector<Cookie> cookies; // Parsed cookies
|
|
size_t content_length = 0;
|
|
|
|
bool valid = false;
|
|
|
|
string_view get_cookie(string_view name) const {
|
|
return CookieHelpers::get_cookie(cookies, name);
|
|
}
|
|
|
|
string session_id() const {
|
|
return string(get_cookie("session_id"));
|
|
}
|
|
};
|