cpp_server/http_request.hpp
2025-06-13 15:22:51 -05:00

32 lines
688 B
C++

#pragma once
#include "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"));
}
};