<commit_before>
#pragma once

#include <string>
#include <vector>
#include <boost/lexical_cast.hpp>
#include "utils.hpp"

namespace cinatra
{
	class Request
	{
	public:
		Request()
			:method_(method_t::UNKNOWN),
			is_body_parsed_(false)
		{

		}

		Request(
			const std::string& url,
			const std::vector<char>& body,
			const std::string& method,
			const std::string& path,
			const CaseMap& query_map,
			const NcaseMultiMap& header
			)
			:url_(url),
			body_(body),
			path_(path),
			query_(query_map),
			header_(header),
			is_body_parsed_(false)
		{
			if (boost::iequals(method, "GET"))
			{
				method_ = method_t::GET;
			}
			else if (boost::iequals(method, "PUT"))
			{
				method_ = method_t::PUT;
			}
			else if (boost::iequals(method, "POST"))
			{
				method_ = method_t::POST;
			}
			else if (boost::iequals(method, "DELETE"))
			{
				method_ = method_t::DELETE;
			}
			else if (boost::iequals(method, "TRACE"))
			{
				method_ = method_t::TRACE;
			}
			else if (boost::iequals(method, "CONNECT"))
			{
				method_ = method_t::CONNECT;
			}
			else if (boost::iequals(method, "HEAD"))
			{
				method_ = method_t::HEAD;
			}
			else if (boost::iequals(method, "OPTIONS"))
			{
				method_ = method_t::OPTIONS;
			}
			else
			{
				method_ = method_t::UNKNOWN;
			}
		}

		enum class method_t
		{
			UNKNOWN,
			GET,
			PUT,
			POST,
			DELETE,
			TRACE,
			CONNECT,
			HEAD,
			OPTIONS
		};

		const std::string& url() const { return url_; }
		method_t method() const { return method_; }

		const std::string& host() const
		{
			return header_.get_val("host");
		}
		const std::vector<char>& body()
		{
			return body_;
		}

		const std::string& path() const { return path_; }
		const CaseMap& query() const { return query_; }
		const NcaseMultiMap&  header() const { return header_; }

		int content_length() const 
		{
			if (header_.get_count("Content-Length") == 0)
			{
				return 0;
			}

			// Բõcast쳣Ҫ쳣ڽhttp headerʱ
			return boost::lexical_cast<int>(header_.get_val("Content-Length"));
		}

		const std::string& raw_cookie()
		{
			return header_.get_val("Cookie");
		}
	private:
		std::string url_;
		std::vector<char> body_;
		method_t method_;
		std::string path_;
		CaseMap query_;
		NcaseMultiMap header_;
		bool is_body_parsed_;
	};
}<commit_msg>删除没用的 is_body_parsed_变量<commit_after>
#pragma once

#include <string>
#include <vector>
#include <boost/lexical_cast.hpp>
#include "utils.hpp"

namespace cinatra
{
	class Request
	{
	public:
		Request()
			:method_(method_t::UNKNOWN)
		{

		}

		Request(
			const std::string& url,
			const std::vector<char>& body,
			const std::string& method,
			const std::string& path,
			const CaseMap& query_map,
			const NcaseMultiMap& header
			)
			:url_(url),
			body_(body),
			path_(path),
			query_(query_map),
			header_(header)
		{
			if (boost::iequals(method, "GET"))
			{
				method_ = method_t::GET;
			}
			else if (boost::iequals(method, "PUT"))
			{
				method_ = method_t::PUT;
			}
			else if (boost::iequals(method, "POST"))
			{
				method_ = method_t::POST;
			}
			else if (boost::iequals(method, "DELETE"))
			{
				method_ = method_t::DELETE;
			}
			else if (boost::iequals(method, "TRACE"))
			{
				method_ = method_t::TRACE;
			}
			else if (boost::iequals(method, "CONNECT"))
			{
				method_ = method_t::CONNECT;
			}
			else if (boost::iequals(method, "HEAD"))
			{
				method_ = method_t::HEAD;
			}
			else if (boost::iequals(method, "OPTIONS"))
			{
				method_ = method_t::OPTIONS;
			}
			else
			{
				method_ = method_t::UNKNOWN;
			}
		}

		enum class method_t
		{
			UNKNOWN,
			GET,
			PUT,
			POST,
			DELETE,
			TRACE,
			CONNECT,
			HEAD,
			OPTIONS
		};

		const std::string& url() const { return url_; }
		method_t method() const { return method_; }

		const std::string& host() const
		{
			return header_.get_val("host");
		}
		const std::vector<char>& body()
		{
			return body_;
		}

		const std::string& path() const { return path_; }
		const CaseMap& query() const { return query_; }
		const NcaseMultiMap&  header() const { return header_; }

		int content_length() const 
		{
			if (header_.get_count("Content-Length") == 0)
			{
				return 0;
			}

			// Բõcast쳣Ҫ쳣ڽhttp headerʱ
			return boost::lexical_cast<int>(header_.get_val("Content-Length"));
		}

		const std::string& raw_cookie()
		{
			return header_.get_val("Cookie");
		}
	private:
		std::string url_;
		std::vector<char> body_;
		method_t method_;
		std::string path_;
		CaseMap query_;
		NcaseMultiMap header_;
	};
}
{'fraction_non_alphanumeric': 0.14636846767050488, 'fraction_numerical': 0.0008857395925597874, 'mean_word_length': 3.151654411764706, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3799838', 'n_tokens_mistral': 2049, 'n_tokens_neox': 1683, 'n_words': 353}