@@ -178,6 +178,15 @@ class no_response_resource : public http_resource
178178 }
179179};
180180
181+ class file_response_resource : public http_resource
182+ {
183+ public:
184+ const http_response render_GET (const http_request& req)
185+ {
186+ return http_response_builder (" test_content" , 200 , " text/plain" ).file_response ();
187+ }
188+ };
189+
181190LT_BEGIN_SUITE (basic_suite)
182191
183192 webserver* ws;
@@ -697,6 +706,24 @@ LT_BEGIN_AUTO_TEST(basic_suite, register_unregister)
697706 }
698707LT_END_AUTO_TEST (register_unregister)
699708
709+ LT_BEGIN_AUTO_TEST (basic_suite, file_serving_resource)
710+ file_response_resource* resource = new file_response_resource();
711+ ws->register_resource (" base" , resource);
712+ curl_global_init (CURL_GLOBAL_ALL );
713+
714+ std::string s;
715+ CURL *curl = curl_easy_init();
716+ CURLcode res;
717+ curl_easy_setopt (curl, CURLOPT_URL , " localhost:8080/base" );
718+ curl_easy_setopt (curl, CURLOPT_HTTPGET , 1L );
719+ curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION , writefunc);
720+ curl_easy_setopt (curl, CURLOPT_WRITEDATA , &s);
721+ res = curl_easy_perform(curl);
722+ LT_ASSERT_EQ (res, 0 );
723+ LT_CHECK_EQ (s, " test content of file\n " );
724+ curl_easy_cleanup (curl);
725+ LT_END_AUTO_TEST (file_serving_resource)
726+
700727LT_BEGIN_AUTO_TEST_ENV ()
701728 AUTORUN_TESTS ()
702729LT_END_AUTO_TEST_ENV()
0 commit comments