Something went wrong. Try again.
An HTTP server written in C++98 projects.intra.42.fr/projects/webserv
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950/* ************************************************************************** *//* *//* ::: :::::::: *//* parse_header.cpp :+: :+: :+: *//* +:+ +:+ +:+ *//* By: bcausseq <bcausseq@42angouleme.fr> +#+ +:+ +#+ *//* +#+#+#+#+#+ +#+ *//* Created: 2026/09/27 21:42:27 by bcausseq #+# #+# *//* Updated: 2026/09/27 23:00:27 by bcausseq ### ########.fr *//* *//* ************************************************************************** */
#include "Header.hpp"#include "server/Client.hpp"#include "utils.hpp"
voidparse_header(Client &c){ std::string in_buf = c.get_in_buffer();
if (in_buf.find("\r\n\r\n") == std::string::npos) return ;
std::string header = in_buf.substr(0, in_buf.find_first_of("\r\n"));
size_t fws = header.find_first_of(' '); size_t lws = header.find_last_of(' '); std::string method = header.substr(0, fws); std::string path = header.substr(fws + 1, lws - 1); std::string version = header.substr(lws + 1);
Header parsed(method, path, version); switch (get_method(parsed.get_method())) { case GET: method_get(parsed, c); break;
case DELETE: method_delete(parsed, c); break; case NOT_IMP: default: send_error_status(parsed, c, 501); break; }}