@@ -507,6 +507,50 @@ void twelfth() {
507507 .get ();
508508}
509509
510+ void thirtheenth () {
511+ // Create an instance of the rest client
512+ auto rest_client = RestClient::Create ();
513+
514+ // Create a coroutine to send our request
515+ rest_client->ProcessWithPromise ([&](Context& ctx) {
516+ // This is a co-routine, running in a worker-thread
517+
518+ // Construct a request to the server
519+ auto reply = RequestBuilder (ctx)
520+ .Get (" https://www.google.com/search" )
521+
522+ /* Add some request arguments
523+ * Here we use Google search with arguments:
524+ *
525+ * hl=en
526+ * q=site:lastviking.eu+stbl
527+ *
528+ * which tells Google to search for 'stbl' at the site lastviking.eu,
529+ * using the English language.
530+ *
531+ * (I believe Google is recruiting their product-owners from Hell.
532+ * One of their more annoying treats is to use geo-location in
533+ * stead of browser-settings to determine the language of the
534+ * Google web pages.
535+ * Ever used Google's services from Russia? Unless you read
536+ * Russian - just don't! Or add the 'hl' argument (which is
537+ * probably what the Google developers do when they travel)
538+ */
539+
540+ .Argument (" hl" , " en" )
541+ .Argument (" q" , " site:lastviking.eu+stbl" )
542+
543+ // Send the request
544+ .Execute ();
545+
546+ // Fetch the payload asynchronously and send it to standard output
547+ std::cout << reply->GetBodyAsString ();
548+
549+ // Return the post instance trough a C++ future<>
550+ return ;
551+ });
552+ }
553+
510554int main () {
511555
512556 namespace logging = boost::log;
@@ -552,6 +596,9 @@ int main() {
552596 cout << " Twelfth: " << endl;
553597 twelfth ();
554598
599+ cout << " Thirtheenth: " << endl;
600+ thirtheenth ();
601+
555602 } catch (const exception& ex) {
556603 cerr << " Something threw up: " << ex.what () << endl;
557604 return 1 ;
0 commit comments