| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,6 +43,7 @@ void resource_init(map<string, bool>& allowed_methods) | |||
| 43 | 43 | allowed_methods[MHD_HTTP_METHOD_TRACE] = true; | |
| 44 | 44 | allowed_methods[MHD_HTTP_METHOD_CONNECT] = true; | |
| 45 | 45 | allowed_methods[MHD_HTTP_METHOD_OPTIONS] = true; | |
| 46 | + allowed_methods[MHD_HTTP_METHOD_PATCH] = true; | ||
| 46 | 47 | } | |
| 47 | 48 | ||
| 48 | 49 | namespace details | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -205,6 +205,7 @@ const std::string http_utils::http_method_options = MHD_HTTP_METHOD_OPTIONS; | |||
| 205 | 205 | const std::string http_utils::http_method_post = MHD_HTTP_METHOD_POST; | |
| 206 | 206 | const std::string http_utils::http_method_put = MHD_HTTP_METHOD_PUT; | |
| 207 | 207 | const std::string http_utils::http_method_trace = MHD_HTTP_METHOD_TRACE; | |
| 208 | + const std::string http_utils::http_method_patch = MHD_HTTP_METHOD_PATCH; | ||
| 208 | 209 | ||
| 209 | 210 | const std::string http_utils::http_post_encoding_form_urlencoded = | |
| 210 | 211 | MHD_HTTP_POST_ENCODING_FORM_URLENCODED; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -136,6 +136,15 @@ class http_resource | |||
| 136 | 136 | { | |
| 137 | 137 | return render(req); | |
| 138 | 138 | } | |
| 139 | + /** | ||
| 140 | + * Method used to answer to a PATCH request | ||
| 141 | + * @param req Request passed through http | ||
| 142 | + * @return A http_response object | ||
| 143 | + **/ | ||
| 144 | + virtual const std::shared_ptr<http_response> render_PATCH(const http_request& req) | ||
| 145 | + { | ||
| 146 | + return render(req); | ||
| 147 | + } | ||
| 139 | 148 | /** | |
| 140 | 149 | * Method used to answer to a CONNECT request | |
| 141 | 150 | * @param req Request passed through http | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -102,6 +102,7 @@ class http_utils | |||
| 102 | 102 | static const short http_method_post_code; | |
| 103 | 103 | static const short http_method_put_code; | |
| 104 | 104 | static const short http_method_trace_code; | |
| 105 | + static const short http_method_patch_code; | ||
| 105 | 106 | static const short http_method_unknown_code; | |
| 106 | 107 | ||
| 107 | 108 | static const int http_continue; | |
@@ -224,6 +225,7 @@ class http_utils | |||
| 224 | 225 | static const std::string http_method_post; | |
| 225 | 226 | static const std::string http_method_put; | |
| 226 | 227 | static const std::string http_method_trace; | |
| 228 | + static const std::string http_method_patch; | ||
| 227 | 229 | ||
| 228 | 230 | static const std::string http_post_encoding_form_urlencoded; | |
| 229 | 231 | static const std::string http_post_encoding_multipart_formdata; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -789,6 +789,11 @@ int webserver::answer_to_connection(void* cls, MHD_Connection* connection, | |||
| 789 | 789 | mr->callback = &http_resource::render_DELETE; | |
| 790 | 790 | body = true; | |
| 791 | 791 | } | |
| 792 | + else if (0 == strcasecmp(method, http_utils::http_method_patch.c_str())) | ||
| 793 | + { | ||
| 794 | + mr->callback = &http_resource::render_PATCH; | ||
| 795 | + body = true; | ||
| 796 | + } | ||
| 792 | 797 | else if (0 == strcasecmp(method, http_utils::http_method_head.c_str())) | |
| 793 | 798 | { | |
| 794 | 799 | mr->callback = &http_resource::render_HEAD; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -158,6 +158,10 @@ class complete_test_resource : public http_resource | |||
| 158 | 158 | { | |
| 159 | 159 | return shared_ptr<string_response>(new string_response("OK", 200, "text/plain")); | |
| 160 | 160 | } | |
| 161 | + const shared_ptr<http_response> render_PATCH(const http_request& req) | ||
| 162 | + { | ||
| 163 | + return shared_ptr<string_response>(new string_response("OK", 200, "text/plain")); | ||
| 164 | + } | ||
| 161 | 165 | }; | |
| 162 | 166 | ||
| 163 | 167 | class only_render_resource : public http_resource | |
@@ -483,6 +487,14 @@ LT_BEGIN_AUTO_TEST(basic_suite, complete) | |||
| 483 | 487 | curl_easy_cleanup(curl); | |
| 484 | 488 | } | |
| 485 | 489 | ||
| 490 | + { | ||
| 491 | + CURL* curl = curl_easy_init(); | ||
| 492 | + curl_easy_setopt(curl, CURLOPT_URL, "localhost:8080/base"); | ||
| 493 | + curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PATCH"); | ||
| 494 | + CURLcode res = curl_easy_perform(curl); | ||
| 495 | + LT_ASSERT_EQ(res, 0); | ||
| 496 | + curl_easy_cleanup(curl); | ||
| 497 | + } | ||
| 486 | 498 | /* | |
| 487 | 499 | { | |
| 488 | 500 | CURL* curl = curl_easy_init(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments