File tree Expand file tree Collapse file tree 2 files changed +625
-0
lines changed
Expand file tree Collapse file tree 2 files changed +625
-0
lines changed Original file line number Diff line number Diff line change 1+ #include " littletest.hpp"
2+ #include < curl/curl.h>
3+ #include " httpserver.hpp"
4+
5+ using namespace httpserver ;
6+
7+ class simple_resource : public http_resource
8+ {
9+ public:
10+ virtual void render_GET (const http_request& req, http_response** res)
11+ {
12+ *res = new http_string_response (" OK" , 200 , " text/plain" );
13+ }
14+ };
15+
16+ LT_BEGIN_SUITE (basic_suite)
17+
18+ webserver* ws;
19+ simple_resource* res;
20+
21+ void set_up ()
22+ {
23+ ws = new webserver (create_webserver (8080 ));
24+ res = new simple_resource ();
25+ ws->register_resource (" base" , res);
26+ ws->start (false );
27+ }
28+
29+ void tier_down ()
30+ {
31+ ws->stop ();
32+ delete ws;
33+ delete res;
34+ }
35+ LT_END_SUITE (basic_suite)
36+
37+ LT_BEGIN_AUTO_TEST(basic_suite, read_body)
38+ curl_global_init(CURL_GLOBAL_ALL);
39+ CURL *curl = curl_easy_init();
40+ CURLcode res;
41+ curl_easy_setopt (curl, CURLOPT_URL, " localhost:8080/base" );
42+ curl_easy_setopt (curl, CURLOPT_HTTPGET, 1L );
43+ res = curl_easy_perform(curl);
44+
45+ LT_ASSERT_EQ (res, 0 );
46+
47+ LT_END_AUTO_TEST (read_body)
48+
49+
50+ LT_BEGIN_AUTO_TEST_ENV()
51+ AUTORUN_TESTS()
52+ LT_END_AUTO_TEST_ENV()
You can’t perform that action at this time.
0 commit comments