{"id":2599,"date":"2017-11-19T23:23:12","date_gmt":"2017-11-19T21:23:12","guid":{"rendered":"http:\/\/mariusbancila.ro\/blog\/?p=2599"},"modified":"2017-11-20T01:32:27","modified_gmt":"2017-11-19T23:32:27","slug":"revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10","status":"publish","type":"post","link":"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/","title":{"rendered":"Revisited: Full-fledged client-server example with C++ REST SDK 2.10"},"content":{"rendered":"<p>Four years ago I wrote a <a href=\"http:\/\/mariusbancila.ro\/blog\/2013\/08\/19\/full-fledged-client-server-example-with-cpprest-sdk-110\/\">blog post<\/a> that shown how to build a web server using the <tt>http_listener<\/tt> from the <a href=\"https:\/\/github.com\/Microsoft\/cpprestsdk\">C++ REST SDK<\/a> library as well as a client application that consumed the exposed resources. Over the years there have been various changes to the API from the library and some readers complained the code no longer compiled. Eventually, I decided to revisit that post and update my code to the latest version of the library, which at this time is 2.10.<\/p>\n<p>I will not reiterate all the details described in the former article. However, in summary, the server maintains a dictionary of values (both keys and values are strings). Through HTTP calls a client can retrieve the content of the dictionary, add new values, update or delete existing ones.<\/p>\n<table class=\"coogeegrid\">\n<tr>\n<th>HTTP method<\/th>\n<th>Description<\/th>\n<th>Request<\/th>\n<th>Response<\/th>\n<\/tr>\n<tr>\n<td>GET<\/td>\n<td>retrieves all the key-value pair from the dictionary<\/td>\n<td><\/td>\n<td><tt>{\"one\" : \"100\", \"two\" : \"200\"}<\/tt><\/td>\n<\/tr>\n<tr>\n<td>POST<\/td>\n<td>retrieves the values of the specified keys from the dictionary<\/td>\n<td><tt>[\"one\", \"two\", \"three\"]<\/tt><\/td>\n<td><tt>{\"one\" : \"100\", \"three\" : \"<nil>\", \"two\" : \"200\"}<\/tt><\/td>\n<\/tr>\n<td>PUT<\/td>\n<td>inserts new pairs of key-values in the dictionary; if a key is already found its value is updated<\/td>\n<td><tt>{\"one\" : \"100\", \"two\" : \"200\"}<\/tt><\/td>\n<td><tt>{\"one\" : \"<put>\", \"two\" : \"<put>\"}<\/tt><\/td>\n<\/tr>\n<td>DELETE<\/td>\n<td>deletes the specified keys from the dictionary<\/td>\n<td><tt>[\"one\"]<\/tt><\/td>\n<td><tt>{\"one\" : \"<deleted>\"}<\/tt><\/td>\n<\/tr>\n<\/table>\n<p>Here is the server code:<\/p>\n<pre class=\"lang:c++ decode:true \" >#include &lt;cpprest\/http_listener.h&gt;\r\n#include &lt;cpprest\/json.h&gt;\r\n#pragma comment(lib, \"cpprest_2_10\")\r\n\r\nusing namespace web;\r\nusing namespace web::http;\r\nusing namespace web::http::experimental::listener;\r\n\r\n#include &lt;iostream&gt;\r\n#include &lt;map&gt;\r\n#include &lt;set&gt;\r\n#include &lt;string&gt;\r\nusing namespace std;\r\n\r\n#define TRACE(msg)            wcout &lt;&lt; msg\r\n#define TRACE_ACTION(a, k, v) wcout &lt;&lt; a &lt;&lt; L\" (\" &lt;&lt; k &lt;&lt; L\", \" &lt;&lt; v &lt;&lt; L\")\\n\"\r\n\r\nmap&lt;utility::string_t, utility::string_t&gt; dictionary;\r\n\r\nvoid display_json(\r\n   json::value const &amp; jvalue,\r\n   utility::string_t const &amp; prefix)\r\n{\r\n   wcout &lt;&lt; prefix &lt;&lt; jvalue.serialize() &lt;&lt; endl;\r\n}\r\n\r\nvoid handle_get(http_request request)\r\n{\r\n   TRACE(L\"\\nhandle GET\\n\");\r\n\r\n   auto answer = json::value::object();\r\n\r\n   for (auto const &amp; p : dictionary)\r\n   {\r\n      answer[p.first] = json::value::string(p.second);\r\n   }\r\n\r\n   display_json(json::value::null(), L\"R: \");\r\n   display_json(answer, L\"S: \");\r\n\r\n   request.reply(status_codes::OK, answer);\r\n}\r\n\r\nvoid handle_request(\r\n   http_request request,\r\n   function&lt;void(json::value const &amp;, json::value &amp;)&gt; action)\r\n{\r\n   auto answer = json::value::object();\r\n\r\n   request\r\n      .extract_json()\r\n      .then([&amp;answer, &amp;action](pplx::task&lt;json::value&gt; task) {\r\n         try\r\n         {\r\n            auto const &amp; jvalue = task.get();\r\n            display_json(jvalue, L\"R: \");\r\n\r\n            if (!jvalue.is_null())\r\n            {\r\n               action(jvalue, answer);\r\n            }\r\n         }\r\n         catch (http_exception const &amp; e)\r\n         {\r\n            wcout &lt;&lt; e.what() &lt;&lt; endl;\r\n         }\r\n      })\r\n      .wait();\r\n\r\n   \r\n   display_json(answer, L\"S: \");\r\n\r\n   request.reply(status_codes::OK, answer);\r\n}\r\n\r\nvoid handle_post(http_request request)\r\n{\r\n   TRACE(\"\\nhandle POST\\n\");\r\n\r\n   handle_request(\r\n      request,\r\n      [](json::value const &amp; jvalue, json::value &amp; answer)\r\n   {\r\n      for (auto const &amp; e : jvalue.as_array())\r\n      {\r\n         if (e.is_string())\r\n         {\r\n            auto key = e.as_string();\r\n            auto pos = dictionary.find(key);\r\n\r\n            if (pos == dictionary.end())\r\n            {\r\n               answer[key] = json::value::string(L\"&lt;nil&gt;\");\r\n            }\r\n            else\r\n            {\r\n               answer[pos-&gt;first] = json::value::string(pos-&gt;second);\r\n            }\r\n         }\r\n      }\r\n   });\r\n}\r\n\r\nvoid handle_put(http_request request)\r\n{\r\n   TRACE(\"\\nhandle PUT\\n\");\r\n\r\n   handle_request(\r\n      request,\r\n      [](json::value const &amp; jvalue, json::value &amp; answer)\r\n   {\r\n      for (auto const &amp; e : jvalue.as_object())\r\n      {\r\n         if (e.second.is_string())\r\n         {\r\n            auto key = e.first;\r\n            auto value = e.second.as_string();\r\n\r\n            if (dictionary.find(key) == dictionary.end())\r\n            {\r\n               TRACE_ACTION(L\"added\", key, value);\r\n               answer[key] = json::value::string(L\"&lt;put&gt;\");\r\n            }\r\n            else\r\n            {\r\n               TRACE_ACTION(L\"updated\", key, value);\r\n               answer[key] = json::value::string(L\"&lt;updated&gt;\");\r\n            }\r\n\r\n            dictionary[key] = value;\r\n         }\r\n      }\r\n   });\r\n}\r\n\r\nvoid handle_del(http_request request)\r\n{\r\n   TRACE(\"\\nhandle DEL\\n\");\r\n\r\n   handle_request(\r\n      request,\r\n      [](json::value const &amp; jvalue, json::value &amp; answer)\r\n   {\r\n      set&lt;utility::string_t&gt; keys;\r\n      for (auto const &amp; e : jvalue.as_array())\r\n      {\r\n         if (e.is_string())\r\n         {\r\n            auto key = e.as_string();\r\n\r\n            auto pos = dictionary.find(key);\r\n            if (pos == dictionary.end())\r\n            {\r\n               answer[key] = json::value::string(L\"&lt;failed&gt;\");\r\n            }\r\n            else\r\n            {\r\n               TRACE_ACTION(L\"deleted\", pos-&gt;first, pos-&gt;second);\r\n               answer[key] = json::value::string(L\"&lt;deleted&gt;\");\r\n               keys.insert(key);\r\n            }\r\n         }\r\n      }\r\n\r\n      for (auto const &amp; key : keys)\r\n         dictionary.erase(key);\r\n   });\r\n}\r\n\r\nint main()\r\n{\r\n   http_listener listener(L\"http:\/\/localhost\/restdemo\");\r\n\r\n   listener.support(methods::GET,  handle_get);\r\n   listener.support(methods::POST, handle_post);\r\n   listener.support(methods::PUT,  handle_put);\r\n   listener.support(methods::DEL,  handle_del);\r\n\r\n   try\r\n   {\r\n      listener\r\n         .open()\r\n         .then([&amp;listener]() {TRACE(L\"\\nstarting to listen\\n\"); })\r\n         .wait();\r\n\r\n      while (true);\r\n   }\r\n   catch (exception const &amp; e)\r\n   {\r\n      wcout &lt;&lt; e.what() &lt;&lt; endl;\r\n   }\r\n\r\n   return 0;\r\n}\r\n<\/pre>\n<p>And this is the client code:<\/p>\n<pre class=\"lang:c++ decode:true \" >#include &lt;cpprest\/http_client.h&gt;\r\n#include &lt;cpprest\/json.h&gt;\r\n#pragma comment(lib, \"cpprest_2_10\")\r\n\r\nusing namespace web;\r\nusing namespace web::http;\r\nusing namespace web::http::client;\r\n\r\n#include &lt;iostream&gt;\r\nusing namespace std;\r\n\r\nvoid display_json(\r\n   json::value const &amp; jvalue, \r\n   utility::string_t const &amp; prefix)\r\n{\r\n   wcout &lt;&lt; prefix &lt;&lt; jvalue.serialize() &lt;&lt; endl;\r\n}\r\n\r\npplx::task&lt;http_response&gt; make_task_request(\r\n   http_client &amp; client,\r\n   method mtd,\r\n   json::value const &amp; jvalue)\r\n{\r\n   return (mtd == methods::GET || mtd == methods::HEAD) ?\r\n      client.request(mtd, L\"\/restdemo\") :\r\n      client.request(mtd, L\"\/restdemo\", jvalue);\r\n}\r\n\r\nvoid make_request(\r\n   http_client &amp; client, \r\n   method mtd, \r\n   json::value const &amp; jvalue)\r\n{\r\n   make_task_request(client, mtd, jvalue)\r\n      .then([](http_response response)\r\n      {\r\n         if (response.status_code() == status_codes::OK)\r\n         {\r\n            return response.extract_json();\r\n         }\r\n         return pplx::task_from_result(json::value());\r\n      })\r\n      .then([](pplx::task&lt;json::value&gt; previousTask)\r\n      {\r\n         try\r\n         {\r\n            display_json(previousTask.get(), L\"R: \");\r\n         }\r\n         catch (http_exception const &amp; e)\r\n         {\r\n            wcout &lt;&lt; e.what() &lt;&lt; endl;\r\n         }\r\n      })\r\n      .wait();\r\n}\r\n\r\nint main()\r\n{\r\n   http_client client(U(\"http:\/\/localhost\"));\r\n\r\n   auto putvalue = json::value::object();\r\n   putvalue[L\"one\"] = json::value::string(L\"100\");\r\n   putvalue[L\"two\"] = json::value::string(L\"200\");\r\n\r\n   wcout &lt;&lt; L\"\\nPUT (add values)\\n\";\r\n   display_json(putvalue, L\"S: \");\r\n   make_request(client, methods::PUT, putvalue);\r\n\r\n   auto getvalue = json::value::array();\r\n   getvalue[0] = json::value::string(L\"one\");\r\n   getvalue[1] = json::value::string(L\"two\");\r\n   getvalue[2] = json::value::string(L\"three\");\r\n\r\n   wcout &lt;&lt; L\"\\nPOST (get some values)\\n\";\r\n   display_json(getvalue, L\"S: \");\r\n   make_request(client, methods::POST, getvalue);\r\n\r\n   auto delvalue = json::value::array();\r\n   delvalue[0] = json::value::string(L\"one\");\r\n\r\n   wcout &lt;&lt; L\"\\nDELETE (delete values)\\n\";\r\n   display_json(delvalue, L\"S: \");\r\n   make_request(client, methods::DEL, delvalue);\r\n\r\n   wcout &lt;&lt; L\"\\nPOST (get some values)\\n\";\r\n   display_json(getvalue, L\"S: \");\r\n   make_request(client, methods::POST, getvalue);\r\n\r\n   auto nullvalue = json::value::null();\r\n\r\n   wcout &lt;&lt; L\"\\nGET (get all values)\\n\";\r\n   display_json(nullvalue, L\"S: \");\r\n   make_request(client, methods::GET, nullvalue);\r\n\r\n   return 0;\r\n}<\/pre>\n<p>Notice there are slight changes in the way output is formatted, both in the server and the client application. The rest is mostly unchanged, except for the handling of JSON, that has changed significatly since version 1.1. Again, please see the original post for an explanation of the code.<\/p>\n<p>The output from running these client and server applications is shown below. On the left is the client output, and on the right the server output.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2017\/11\/clientserver.png\" alt=\"\" width=\"806\" height=\"331\" class=\"alignnone size-full wp-image-2607\" srcset=\"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2017\/11\/clientserver.png 806w, https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2017\/11\/clientserver-300x123.png 300w, https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2017\/11\/clientserver-768x315.png 768w\" sizes=\"auto, (max-width: 806px) 100vw, 806px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Four years ago I wrote a blog post that shown how to build a web server using the http_listener from the C++ REST SDK library as well as a client application that consumed the exposed resources. Over the years there have been various changes to the API from the library and some readers complained the &#8230; <a title=\"Revisited: Full-fledged client-server example with C++ REST SDK 2.10\" class=\"read-more\" href=\"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/\" aria-label=\"Read more about Revisited: Full-fledged client-server example with C++ REST SDK 2.10\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","advgb_blocks_editor_width":"","advgb_blocks_columns_visual_guide":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[7,19],"tags":[451,138,528,381],"class_list":["post-2599","post","type-post","status-publish","format-standard","hentry","category-c","category-web","tag-c","tag-library","tag-rest","tag-server"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"This article shows how to build a web server using http_listener from C++ REST SDK and client application to consume it.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Marius Bancila\"\/>\n\t<meta name=\"keywords\" content=\"c++,rest,library,server\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Marius Bancila&#039;s Blog | About code. Mostly on C++\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Revisited: Full-fledged client-server example with C++ REST SDK 2.10\" \/>\n\t\t<meta property=\"og:description\" content=\"This article shows how to build a web server using http_listener from C++ REST SDK and client application to consume it.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2017-11-19T21:23:12+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2017-11-19T23:32:27+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Revisited: Full-fledged client-server example with C++ REST SDK 2.10\" \/>\n\t\t<meta name=\"twitter:description\" content=\"This article shows how to build a web server using http_listener from C++ REST SDK and client application to consume it.\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2017\\\/11\\\/19\\\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\\\/#article\",\"name\":\"Revisited: Full-fledged client-server example with C++ REST SDK 2.10\",\"headline\":\"Revisited: Full-fledged client-server example with C++ REST SDK 2.10\",\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/clientserver.png\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2017\\\/11\\\/19\\\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\\\/#articleImage\",\"width\":806,\"height\":331},\"datePublished\":\"2017-11-19T23:23:12+02:00\",\"dateModified\":\"2017-11-20T01:32:27+02:00\",\"inLanguage\":\"en-US\",\"commentCount\":29,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2017\\\/11\\\/19\\\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2017\\\/11\\\/19\\\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\\\/#webpage\"},\"articleSection\":\"C++, Web, C++, library, REST, server\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2017\\\/11\\\/19\\\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"position\":2,\"name\":\"IT\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"position\":3,\"name\":\"Software\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"name\":\"C++\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"position\":4,\"name\":\"C++\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2017\\\/11\\\/19\\\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\\\/#listItem\",\"name\":\"Revisited: Full-fledged client-server example with C++ REST SDK 2.10\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2017\\\/11\\\/19\\\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\\\/#listItem\",\"position\":5,\"name\":\"Revisited: Full-fledged client-server example with C++ REST SDK 2.10\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"name\":\"C++\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/\",\"name\":\"Marius Bancila\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2017\\\/11\\\/19\\\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Marius Bancila\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2017\\\/11\\\/19\\\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\\\/#webpage\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2017\\\/11\\\/19\\\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\\\/\",\"name\":\"Revisited: Full-fledged client-server example with C++ REST SDK 2.10\",\"description\":\"This article shows how to build a web server using http_listener from C++ REST SDK and client application to consume it.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2017\\\/11\\\/19\\\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2017-11-19T23:23:12+02:00\",\"dateModified\":\"2017-11-20T01:32:27+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Revisited: Full-fledged client-server example with C++ REST SDK 2.10","description":"This article shows how to build a web server using http_listener from C++ REST SDK and client application to consume it.","canonical_url":"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/","robots":"max-image-preview:large","keywords":"c++,rest,library,server","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/#article","name":"Revisited: Full-fledged client-server example with C++ REST SDK 2.10","headline":"Revisited: Full-fledged client-server example with C++ REST SDK 2.10","author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2017\/11\/clientserver.png","@id":"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/#articleImage","width":806,"height":331},"datePublished":"2017-11-19T23:23:12+02:00","dateModified":"2017-11-20T01:32:27+02:00","inLanguage":"en-US","commentCount":29,"mainEntityOfPage":{"@id":"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/#webpage"},"isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/#webpage"},"articleSection":"C++, Web, C++, library, REST, server"},{"@type":"BreadcrumbList","@id":"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog#listItem","position":1,"name":"Home","item":"https:\/\/mariusbancila.ro\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","position":2,"name":"IT","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","position":3,"name":"Software","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","name":"C++"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","position":4,"name":"C++","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/#listItem","name":"Revisited: Full-fledged client-server example with C++ REST SDK 2.10"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/#listItem","position":5,"name":"Revisited: Full-fledged client-server example with C++ REST SDK 2.10","previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","name":"C++"}}]},{"@type":"Organization","@id":"https:\/\/mariusbancila.ro\/blog\/#organization","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","url":"https:\/\/mariusbancila.ro\/blog\/"},{"@type":"Person","@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author","url":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/","name":"Marius Bancila","image":{"@type":"ImageObject","@id":"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g","width":96,"height":96,"caption":"Marius Bancila"}},{"@type":"WebPage","@id":"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/#webpage","url":"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/","name":"Revisited: Full-fledged client-server example with C++ REST SDK 2.10","description":"This article shows how to build a web server using http_listener from C++ REST SDK and client application to consume it.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/#breadcrumblist"},"author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"creator":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"datePublished":"2017-11-19T23:23:12+02:00","dateModified":"2017-11-20T01:32:27+02:00"},{"@type":"WebSite","@id":"https:\/\/mariusbancila.ro\/blog\/#website","url":"https:\/\/mariusbancila.ro\/blog\/","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","inLanguage":"en-US","publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Marius Bancila's Blog | About code. Mostly on C++","og:type":"article","og:title":"Revisited: Full-fledged client-server example with C++ REST SDK 2.10","og:description":"This article shows how to build a web server using http_listener from C++ REST SDK and client application to consume it.","og:url":"https:\/\/mariusbancila.ro\/blog\/2017\/11\/19\/revisited-full-fledged-client-server-example-with-c-rest-sdk-2-10\/","article:published_time":"2017-11-19T21:23:12+00:00","article:modified_time":"2017-11-19T23:32:27+00:00","twitter:card":"summary","twitter:title":"Revisited: Full-fledged client-server example with C++ REST SDK 2.10","twitter:description":"This article shows how to build a web server using http_listener from C++ REST SDK and client application to consume it."},"aioseo_meta_data":{"post_id":"2599","title":"Revisited: Full-fledged client-server example with C++ REST SDK 2.10","description":"This article shows how to build a web server using http_listener from C++ REST SDK and client application to consume it.","keywords":[{"label":"C++","value":"C++"},{"label":"REST","value":"REST"},{"label":"library","value":"library"},{"label":"server","value":"server"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-03-18 21:06:01","updated":"2025-12-12 07:46:59","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"author_meta":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"featured_img":null,"jetpack_publicize_connections":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"uagb_comment_info":29,"uagb_excerpt":"Four years ago I wrote a blog post that shown how to build a web server using the http_listener from the C++ REST SDK library as well as a client application that consumed the exposed resources. Over the years there have been various changes to the API from the library and some readers complained the&hellip;","coauthors":[],"tax_additional":{"categories":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">C++<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/web\/\" class=\"advgb-post-tax-term\">Web<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C++<\/span>","<span class=\"advgb-post-tax-term\">Web<\/span>"]},"tags":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/web\/\" class=\"advgb-post-tax-term\">C++<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/web\/\" class=\"advgb-post-tax-term\">library<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/web\/\" class=\"advgb-post-tax-term\">REST<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/web\/\" class=\"advgb-post-tax-term\">server<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C++<\/span>","<span class=\"advgb-post-tax-term\">library<\/span>","<span class=\"advgb-post-tax-term\">REST<\/span>","<span class=\"advgb-post-tax-term\">server<\/span>"]}},"comment_count":"29","relative_dates":{"created":"Posted 9 years ago","modified":"Updated 9 years ago"},"absolute_dates":{"created":"Posted on November 19, 2017","modified":"Updated on November 20, 2017"},"absolute_dates_time":{"created":"Posted on November 19, 2017 11:23 pm","modified":"Updated on November 20, 2017 1:32 am"},"featured_img_caption":"","series_order":"","jetpack_shortlink":"https:\/\/wp.me\/pYNdv-FV","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/2599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/comments?post=2599"}],"version-history":[{"count":10,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/2599\/revisions"}],"predecessor-version":[{"id":2635,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/2599\/revisions\/2635"}],"wp:attachment":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/media?parent=2599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/categories?post=2599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/tags?post=2599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}