@@ -637,6 +637,62 @@ LT_BEGIN_AUTO_TEST(basic_suite, querystring_processing)
637637 curl_easy_cleanup (curl);
638638LT_END_AUTO_TEST (querystring_processing)
639639
640+ LT_BEGIN_AUTO_TEST(basic_suite, register_unregister)
641+ simple_resource* resource = new simple_resource();
642+ ws->register_resource (" base" , resource);
643+ curl_global_init (CURL_GLOBAL_ALL);
644+
645+ {
646+ std::string s;
647+ CURL *curl = curl_easy_init ();
648+ CURLcode res;
649+ curl_easy_setopt (curl, CURLOPT_URL, " localhost:8080/base" );
650+ curl_easy_setopt (curl, CURLOPT_HTTPGET, 1L );
651+ curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, writefunc);
652+ curl_easy_setopt (curl, CURLOPT_WRITEDATA, &s);
653+ res = curl_easy_perform (curl);
654+ LT_ASSERT_EQ (res, 0 );
655+ LT_CHECK_EQ (s, " OK" );
656+ curl_easy_cleanup (curl);
657+ }
658+
659+ ws->unregister_resource (" base" );
660+ {
661+ std::string s;
662+ CURL *curl = curl_easy_init ();
663+ CURLcode res;
664+ curl_easy_setopt (curl, CURLOPT_URL, " localhost:8080/base" );
665+ curl_easy_setopt (curl, CURLOPT_HTTPGET, 1L );
666+ curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, writefunc);
667+ curl_easy_setopt (curl, CURLOPT_WRITEDATA, &s);
668+ res = curl_easy_perform (curl);
669+ LT_ASSERT_EQ (res, 0 );
670+
671+ long http_code = 0 ;
672+ curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &http_code);
673+ LT_ASSERT_EQ (http_code, 404 );
674+
675+ LT_CHECK_EQ (s, " Not Found" );
676+
677+ curl_easy_cleanup (curl);
678+ }
679+
680+ ws->register_resource (" base" , resource);
681+ {
682+ std::string s;
683+ CURL *curl = curl_easy_init ();
684+ CURLcode res;
685+ curl_easy_setopt (curl, CURLOPT_URL, " localhost:8080/base" );
686+ curl_easy_setopt (curl, CURLOPT_HTTPGET, 1L );
687+ curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, writefunc);
688+ curl_easy_setopt (curl, CURLOPT_WRITEDATA, &s);
689+ res = curl_easy_perform (curl);
690+ LT_ASSERT_EQ (res, 0 );
691+ LT_CHECK_EQ (s, " OK" );
692+ curl_easy_cleanup (curl);
693+ }
694+ LT_END_AUTO_TEST (register_unregister)
695+
640696LT_BEGIN_AUTO_TEST_ENV()
641697 AUTORUN_TESTS()
642698LT_END_AUTO_TEST_ENV()
0 commit comments