diff --git a/srcs/HttpRequest/BaseKeyValueMap.cpp b/srcs/HttpRequest/BaseKeyValueMap/BaseKeyValueMap.cpp similarity index 100% rename from srcs/HttpRequest/BaseKeyValueMap.cpp rename to srcs/HttpRequest/BaseKeyValueMap/BaseKeyValueMap.cpp diff --git a/srcs/HttpRequest/BaseKeyValueMap/BaseKeyValueMap.hpp b/srcs/HttpRequest/BaseKeyValueMap/BaseKeyValueMap.hpp new file mode 100644 index 00000000..b19ff7fe --- /dev/null +++ b/srcs/HttpRequest/BaseKeyValueMap/BaseKeyValueMap.hpp @@ -0,0 +1,19 @@ +#ifndef BASEKEYVALUEMAP_HPP +#define BASEKEYVALUEMAP_HPP + +#include +#include + +class BaseKeyValueMap +{ + private: + + public: + BaseKeyValueMap(void); + BaseKeyValueMap(const BaseKeyValueMap &other); + virtual ~BaseKeyValueMap(); + + virtual void show_value() = 0; +}; + +#endif \ No newline at end of file diff --git a/srcs/HttpRequest/HttpRequest.cpp b/srcs/HttpRequest/HttpRequest/HttpRequest.cpp similarity index 100% rename from srcs/HttpRequest/HttpRequest.cpp rename to srcs/HttpRequest/HttpRequest/HttpRequest.cpp diff --git a/srcs/HttpRequest/HttpRequest/HttpRequest.hpp b/srcs/HttpRequest/HttpRequest/HttpRequest.hpp new file mode 100644 index 00000000..23024b6a --- /dev/null +++ b/srcs/HttpRequest/HttpRequest/HttpRequest.hpp @@ -0,0 +1,155 @@ +#ifndef HTTPREQUEST_HPP +#define HTTPREQUEST_HPP + +#include +#include +#include +#include +#include + +#include "BaseKeyValueMap.hpp" +#include "HandlingString.hpp" +#include "RequestLine.hpp" +#include "ValueWeightArraySet.hpp" +#include "ValueArraySet.hpp" +#include "ValueSet.hpp" +#include "TwoValueSet.hpp" +#include "ValueMap.hpp" +#include "ValueDateSet.hpp" + +class BaseKeyValueMap; + +class RequestLine; +class ValueWeightArraySet; +class ValueArraySet; +class ValueSet; +class TwoValueSet; +class ValueMap; +class ValueDateSet; + +class HttpRequest +{ + private: + RequestLine _requestline; + std::map inputvalue_functionmap; + std::map request_keyvalue_map; + + HttpRequest(); + HttpRequest(const HttpRequest &other); + + bool check_keyword_exist(const std::string &key); + std::string obtain_request_key(const std::string value); + std::string obtain_request_value(const std::string value); + + TwoValueSet *ready_TwoValueSet(const std::string &value); + TwoValueSet *ready_TwoValueSet(const std::string &value, char delimiter); + ValueArraySet *ready_ValueArraySet(const std::string &value); + ValueDateSet *ready_ValueDateSet(const std::string &value); + ValueMap *ready_ValueMap(const std::string &value); + ValueMap *ready_ValueMap(const std::string &only_value, const std::string &value); + ValueSet *ready_ValueSet(const std::string &value); + ValueWeightArraySet *ready_ValueWeightArraySet(const std::string &value); + void ready_functionmap(void); + + double _status_code; + + public: + + HttpRequest(const std::string &all_request_text); + ~HttpRequest(); + + // void set_all_method(); + void set_accept(const std::string &key, const std::string &value); + void set_accept_ch(const std::string &key,const std::string &value); + void set_accept_charset(const std::string &key,const std::string &value); + void set_accept_encoding(const std::string &key,const std::string &value); + void set_accept_language(const std::string &key,const std::string &value); + bool check_accept_langage_valueword(const std::string &value); + // void set_//方かわからん + void set_accept_post(const std::string &key,const std::string &value); + void set_accept_ranges(const std::string &key,const std::string &value); + void set_access_control_allow_credentials(const std::string &key,const std::string &value); + void set_access_control_allow_headers(const std::string &key,const std::string &value); + void set_access_control_allow_methods(const std::string &key,const std::string &value); + void set_access_control_allow_origin(const std::string &key,const std::string &value); + void set_access_control_expose_headers(const std::string &key,const std::string &value); + void set_access_control_max_age(const std::string &key,const std::string &value); + void set_access_control_request_headers(const std::string &key,const std::string &value); + void set_access_control_request_method(const std::string &key,const std::string &value); + void set_age(const std::string &key,const std::string &value); + void set_allow(const std::string &key,const std::string &value); + void set_alt_svc(const std::string &key,const std::string &value); + void set_alt_used(const std::string &key,const std::string &value); + void set_authorization(const std::string &key, const std::string &value); + // void set//か全くわからない うまく分けられん + void set_clear_site_data(const std::string &key,const std::string &value); + void set_connection(const std::string &key,const std::string &value); + void set_content_disponesition(const std::string &key,const std::string &value); + void set_content_encoding(const std::string &key,const std::string &value); + void set_content_language(const std::string &key,const std::string &value); + void set_content_length(const std::string &key,const std::string &value); + void set_content_location(const std::string &key,const std::string &value); + void set_content_range(const std::string &key,const std::string &value); + void set_content_security_policy(const std::string &key,const std::string &value); + void set_content_security_policy_report_only(const std::string &key,const std::string &value); + void set_content_type(const std::string &key,const std::string &value); + void set_cookie(const std::string &key,const std::string &value); + void set_cross_origin_embedder_policy(const std::string &key,const std::string &value); + void set_cross_origin_opener_policy(const std::string &key,const std::string &value); + void set_cross_origin_resource_policy(const std::string &key,const std::string &value); + void set_date(const std::string &key,const std::string &value); + void set_etag(const std::string &key,const std::string &value); + void set_expect(const std::string &key,const std::string &value); + // void set//ているっぽくて対応したくない + void set_expires(const std::string &key,const std::string &value); + void set_forwarded(const std::string &key,const std::string &value); + void set_email(const std::string &key,const std::string &value); + void set_from(const std::string &key,const std::string &value); + void set_host(const std::string &key,const std::string &value); + void set_if_match(const std::string &key,const std::string &value); + void set_if_modified_since(const std::string &key,const std::string &value); + void set_if_none_match(const std::string &key,const std::string &value); + void set_if_range(const std::string &key,const std::string &value); + void set_if_unmodified_since(const std::string &key,const std::string &value); + void set_keep_alive(const std::string &key,const std::string &value); + void set_last_modified(const std::string &key,const std::string &value); + void set_link(const std::string &key,const std::string &value); + void set_location(const std::string &key,const std::string &value); + void set_max_forwards(const std::string &key,const std::string &value); + void set_origin(const std::string &key,const std::string &value); + void set_permission_policy(const std::string &key,const std::string &value); + void set_proxy_authenticate(const std::string &key,const std::string &value); + void set_proxy_authorization(const std::string &key,const std::string &value); + // void set//れどれが当てはまるかわからん + void set_referer(const std::string &key,const std::string &value); + void set_referrer_policy(const std::string &key,const std::string &value); + void set_retry_after(const std::string &key,const std::string &value); + void set_sec_fetch_dest(const std::string &key,const std::string &value); + void set_sec_fetch_mode(const std::string &key,const std::string &value); + void set_sec_fetch_site(const std::string &key,const std::string &value); + void set_sec_fetch_user(const std::string &key,const std::string &value); + void set_sec_purpose(const std::string &key,const std::string &value); + void set_sec_websocket_accept(const std::string &key,const std::string &value); + void set_server(const std::string &key,const std::string &value); + void set_servertiming(const std::string &key,const std::string &value); + void set_service_worker_navigation_preload(const std::string &key,const std::string &value); + void set_set_cookie(const std::string &key,const std::string &value); + void set_sourcemap(const std::string &key,const std::string &value); + void set_strict_transport_security(const std::string &key,const std::string &value); + void set_te(const std::string &key,const std::string &value); + void set_timing_allow_origin(const std::string &key,const std::string &value); + void set_trailer(const std::string &key,const std::string &value); + void set_transfer_encoding(const std::string &key,const std::string &value); + void set_upgrade(const std::string &key,const std::string &value); + void set_upgrade_insecure_requests(const std::string &key,const std::string &value); + void set_user_agent(const std::string &key,const std::string &value); + void set_vary(const std::string &key,const std::string &value); + void set_via(const std::string &key,const std::string &value); + void set_www_authenticate(const std::string &key,const std::string &value); + void set_x_xss_protection(const std::string &key,const std::string &value); + + //debug関数 + void show_requestinfs(void); +}; + +#endif \ No newline at end of file diff --git a/srcs/HttpRequest/RequestLine.cpp b/srcs/HttpRequest/RequestLine/RequestLine.cpp similarity index 100% rename from srcs/HttpRequest/RequestLine.cpp rename to srcs/HttpRequest/RequestLine/RequestLine.cpp diff --git a/srcs/HttpRequest/RequestLine/RequestLine.hpp b/srcs/HttpRequest/RequestLine/RequestLine.hpp new file mode 100644 index 00000000..d0ce9149 --- /dev/null +++ b/srcs/HttpRequest/RequestLine/RequestLine.hpp @@ -0,0 +1,31 @@ +#ifndef REQUESTLINE_HPP +#define REQUESTLINE_HPP + +#include +#include +#include + +class RequestLine +{ + private: + std::string _method; + std::string _target_page; + std::string _version; + + RequestLine(const RequestLine &other); + RequestLine& operator=(const RequestLine &other); + + public: + RequestLine(); + ~RequestLine(); + + void set_value(const std::string &line); + + std::string get_method(void) const; + std::string get_target_page(void) const; + std::string get_version(void) const; + + void show_requestline(void) const; +}; + +#endif \ No newline at end of file diff --git a/srcs/HttpRequest/TwoValueSet.cpp b/srcs/HttpRequest/TwoValueSet/TwoValueSet.cpp similarity index 100% rename from srcs/HttpRequest/TwoValueSet.cpp rename to srcs/HttpRequest/TwoValueSet/TwoValueSet.cpp diff --git a/srcs/HttpRequest/TwoValueSet/TwoValueSet.hpp b/srcs/HttpRequest/TwoValueSet/TwoValueSet.hpp new file mode 100644 index 00000000..da47b21b --- /dev/null +++ b/srcs/HttpRequest/TwoValueSet/TwoValueSet.hpp @@ -0,0 +1,27 @@ +#ifndef TWOVALUESET_HPP +#define TWOVALUESET_HPP + +#include +#include +#include "BaseKeyValueMap.hpp" + +class TwoValueSet: public BaseKeyValueMap +{ + private: + std::string _firstvalue; + std::string _secondValue; + + public: + TwoValueSet(); + TwoValueSet(std::string const &first_value); + TwoValueSet(const std::string &first_value, const std::string &second_value); + TwoValueSet& operator=(const TwoValueSet &other); + ~TwoValueSet(); + + std::string get_firstvalue(void) const; + std::string get_secondvalue(void) const; + + void show_value(void); +}; + +#endif \ No newline at end of file diff --git a/srcs/HttpRequest/ValueArraySet.cpp b/srcs/HttpRequest/ValueArraySet/ValueArraySet.cpp similarity index 100% rename from srcs/HttpRequest/ValueArraySet.cpp rename to srcs/HttpRequest/ValueArraySet/ValueArraySet.cpp diff --git a/srcs/HttpRequest/ValueArraySet/ValueArraySet.hpp b/srcs/HttpRequest/ValueArraySet/ValueArraySet.hpp new file mode 100644 index 00000000..1b1f970c --- /dev/null +++ b/srcs/HttpRequest/ValueArraySet/ValueArraySet.hpp @@ -0,0 +1,27 @@ +#ifndef VALUEARRAYSET_HPP +#define VALUEARRAYSET_HPP + +#include +#include +#include + +#include "BaseKeyValueMap.hpp" + +class ValueArraySet: public BaseKeyValueMap +{ + private: + std::vector _value_array; + + public: + ValueArraySet(); + ValueArraySet(const ValueArraySet &other); + ValueArraySet(const std::vector &value_array); + ValueArraySet &operator=(const ValueArraySet &other); + ~ValueArraySet(); + + std::vector get_value_array(void) const; + + void show_value(void); +}; + +#endif \ No newline at end of file diff --git a/srcs/HttpRequest/ValueDateSet.cpp b/srcs/HttpRequest/ValueDateSet/ValueDateSet.cpp similarity index 100% rename from srcs/HttpRequest/ValueDateSet.cpp rename to srcs/HttpRequest/ValueDateSet/ValueDateSet.cpp diff --git a/srcs/HttpRequest/ValueDateSet/ValueDateSet.hpp b/srcs/HttpRequest/ValueDateSet/ValueDateSet.hpp new file mode 100644 index 00000000..455acf57 --- /dev/null +++ b/srcs/HttpRequest/ValueDateSet/ValueDateSet.hpp @@ -0,0 +1,39 @@ +#ifndef VALUEDATESET_HPP +#define VALUEDATESET_HPP + +#include +#include +#include + +#include "BaseKeyValueMap.hpp" + +class ValueDateSet: public BaseKeyValueMap +{ + private: + std::string _day_name; + std::string _day; + std::string _month; + std::string _year; + std::string _hour; + std::string _minute; + std::string _second; + + public: + ValueDateSet(); + ValueDateSet(const ValueDateSet &other); + ValueDateSet& operator=(const ValueDateSet &other); + ValueDateSet(const std::string &date_format); + ~ValueDateSet(); + + std::string get_valuedateset_day_name() const; + std::string get_valuedateset_day() const; + std::string get_valuedateset_month() const; + std::string get_valuedateset_year() const; + std::string get_valuedateset_hour() const; + std::string get_valuedateset_minute() const; + std::string get_valuedateset_second() const; + + void show_value(); +}; + +#endif \ No newline at end of file diff --git a/srcs/HttpRequest/ValueMap.cpp b/srcs/HttpRequest/ValueMap/ValueMap.cpp similarity index 100% rename from srcs/HttpRequest/ValueMap.cpp rename to srcs/HttpRequest/ValueMap/ValueMap.cpp diff --git a/srcs/HttpRequest/ValueMap/ValueMap.hpp b/srcs/HttpRequest/ValueMap/ValueMap.hpp new file mode 100644 index 00000000..0f17d980 --- /dev/null +++ b/srcs/HttpRequest/ValueMap/ValueMap.hpp @@ -0,0 +1,34 @@ +#ifndef VALUEMAP_HPP +#define VALUEMAP_HPP + +#include +#include +#include + +#include "BaseKeyValueMap.hpp" + +class ValueMap: public BaseKeyValueMap +{ + private: + std::string _only_value; + std::map _value_map; + + public: + ValueMap(); + ValueMap(const ValueMap &other); + ValueMap& operator=(const ValueMap &other); + ValueMap(const std::string &value, std::map value_map); + ValueMap(std::map value_map); + ~ValueMap(); + + void set_value(const std::string &only_value, const std::map &value_map); + void set_value(const std::string &only_value); + void set_value(const std::map &value_map); + + std::string get_only_value(void) const; + std::map get_value_map(void) const; + + void show_value(); +}; + +#endif \ No newline at end of file diff --git a/srcs/HttpRequest/ValueSet.cpp b/srcs/HttpRequest/ValueSet/ValueSet.cpp similarity index 100% rename from srcs/HttpRequest/ValueSet.cpp rename to srcs/HttpRequest/ValueSet/ValueSet.cpp diff --git a/srcs/HttpRequest/ValueSet/ValueSet.hpp b/srcs/HttpRequest/ValueSet/ValueSet.hpp new file mode 100644 index 00000000..018a01f4 --- /dev/null +++ b/srcs/HttpRequest/ValueSet/ValueSet.hpp @@ -0,0 +1,27 @@ +#ifndef VALUESET_HPP +#define VALUESET_HPP + +#include +#include +#include + +#include "BaseKeyValueMap.hpp" + +class ValueSet: public BaseKeyValueMap +{ + private: + std::string _value; + + public: + ValueSet(); + ValueSet(const ValueSet &other); + ValueSet &operator=(const ValueSet &other); + ValueSet(const std::string &value); + ~ValueSet(); + + std::string get_value_set(void) const; + + void show_value(); +}; + +#endif \ No newline at end of file diff --git a/srcs/HttpRequest/ValueWeightArraySet.cpp b/srcs/HttpRequest/ValueWeightArraySet/ValueWeightArraySet.cpp similarity index 100% rename from srcs/HttpRequest/ValueWeightArraySet.cpp rename to srcs/HttpRequest/ValueWeightArraySet/ValueWeightArraySet.cpp diff --git a/srcs/HttpRequest/ValueWeightArraySet/ValueWeightArraySet.hpp b/srcs/HttpRequest/ValueWeightArraySet/ValueWeightArraySet.hpp new file mode 100644 index 00000000..f4de72e9 --- /dev/null +++ b/srcs/HttpRequest/ValueWeightArraySet/ValueWeightArraySet.hpp @@ -0,0 +1,27 @@ +#ifndef VALUEWEIGHTARRAYSET_HPP +#define VALUEWEIGHTARRAYSET_HPP + +#include +#include +#include "HandlingString.hpp" + +#include "BaseKeyValueMap.hpp" + +class ValueWeightArraySet: public BaseKeyValueMap +{ + private: + std::map _valueweight_set;//map型で入れるが、どうせなら重みを加味したようなインプットの流れにしておけば取り出す時に非常に楽になるのでは? + + public: + ValueWeightArraySet(); + ValueWeightArraySet(const ValueWeightArraySet &other); + ValueWeightArraySet &operator=(const ValueWeightArraySet &other); + ValueWeightArraySet(std::map &valueweight_set); + ~ValueWeightArraySet(); + + std::map get_valueweight_set(void) const; + + void show_value(); +}; + +#endif \ No newline at end of file