|
21 | 21 | #include "littletest.hpp" |
22 | 22 | #include <curl/curl.h> |
23 | 23 | #include <string> |
| 24 | +#include <sstream> |
24 | 25 | #include <map> |
25 | 26 | #include "string_utilities.hpp" |
26 | 27 | #include "httpserver.hpp" |
@@ -135,6 +136,20 @@ class querystring_resource : public http_resource |
135 | 136 | } |
136 | 137 | }; |
137 | 138 |
|
| 139 | +class path_pieces_resource : public http_resource |
| 140 | +{ |
| 141 | + public: |
| 142 | + const shared_ptr<http_response> render_GET(const http_request& req) |
| 143 | + { |
| 144 | + std::stringstream ss; |
| 145 | + for (unsigned int i = 0; i < req.get_path_pieces().size(); i++) |
| 146 | + { |
| 147 | + ss << req.get_path_piece(i) << ","; |
| 148 | + } |
| 149 | + return shared_ptr<string_response>(new string_response(ss.str(), 200, "text/plain")); |
| 150 | + } |
| 151 | +}; |
| 152 | + |
138 | 153 | class complete_test_resource : public http_resource |
139 | 154 | { |
140 | 155 | public: |
@@ -959,6 +974,24 @@ LT_BEGIN_AUTO_TEST(basic_suite, response_is_printable) |
959 | 974 | curl_easy_cleanup(curl); |
960 | 975 | LT_END_AUTO_TEST(response_is_printable) |
961 | 976 |
|
| 977 | +LT_BEGIN_AUTO_TEST(basic_suite, long_path_pieces) |
| 978 | + path_pieces_resource resource; |
| 979 | + ws->register_resource("/settings", &resource, true); |
| 980 | + curl_global_init(CURL_GLOBAL_ALL); |
| 981 | + |
| 982 | + std::string s; |
| 983 | + CURL *curl = curl_easy_init(); |
| 984 | + CURLcode res; |
| 985 | + curl_easy_setopt(curl, CURLOPT_URL, "localhost:8080/settings/somestringthatisreallylong/with_really_a_lot_of_content/and_underscores_and_looooooooooooooooooong_stuff"); |
| 986 | + curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L); |
| 987 | + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc); |
| 988 | + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &s); |
| 989 | + res = curl_easy_perform(curl); |
| 990 | + LT_ASSERT_EQ(res, 0); |
| 991 | + LT_CHECK_EQ(s, "settings,somestringthatisreallylong,with_really_a_lot_of_content,and_underscores_and_looooooooooooooooooong_stuff,"); |
| 992 | + curl_easy_cleanup(curl); |
| 993 | +LT_END_AUTO_TEST(long_path_pieces) |
| 994 | + |
962 | 995 | LT_BEGIN_AUTO_TEST_ENV() |
963 | 996 | AUTORUN_TESTS() |
964 | 997 | LT_END_AUTO_TEST_ENV() |
0 commit comments