summary refs log tree commit diff stats
path: root/advice.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-03-13 16:25:01 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-03-13 16:25:01 -0400
commit685361eaf3563d97c3d0f89f3853299948dc770f (patch)
tree31f75dc19e7f42782cdb75bb3af483356e48028a /advice.cpp
parentadc3efe6a834ae04194ff3637aaadb71880b5c21 (diff)
downloadadvice-685361eaf3563d97c3d0f89f3853299948dc770f.tar.gz
advice-685361eaf3563d97c3d0f89f3853299948dc770f.tar.bz2
advice-685361eaf3563d97c3d0f89f3853299948dc770f.zip
Added timeout to image downloads
Diffstat (limited to 'advice.cpp')
-rw-r--r--advice.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/advice.cpp b/advice.cpp index ab16571..c3852b0 100644 --- a/advice.cpp +++ b/advice.cpp
@@ -101,6 +101,8 @@ void advice::run() const
101 curl::curl_easy lsthandle(lstios); 101 curl::curl_easy lsthandle(lstios);
102 std::string lsturl = pictured.getNotion().getImageNetUrl(); 102 std::string lsturl = pictured.getNotion().getImageNetUrl();
103 lsthandle.add<CURLOPT_URL>(lsturl.c_str()); 103 lsthandle.add<CURLOPT_URL>(lsturl.c_str());
104 lsthandle.add<CURLOPT_CONNECTTIMEOUT>(30);
105 lsthandle.add<CURLOPT_TIMEOUT>(300);
104 106
105 try 107 try
106 { 108 {
@@ -158,6 +160,7 @@ void advice::run() const
158 imghandle.add<CURLOPT_HTTPHEADER>(headers.get()); 160 imghandle.add<CURLOPT_HTTPHEADER>(headers.get());
159 imghandle.add<CURLOPT_URL>(url.c_str()); 161 imghandle.add<CURLOPT_URL>(url.c_str());
160 imghandle.add<CURLOPT_CONNECTTIMEOUT>(30); 162 imghandle.add<CURLOPT_CONNECTTIMEOUT>(30);
163 imghandle.add<CURLOPT_TIMEOUT>(300);
161 164
162 try 165 try
163 { 166 {
@@ -202,7 +205,7 @@ void advice::run() const
202 { 205 {
203 throw could_not_get_images(); 206 throw could_not_get_images();
204 } 207 }
205 208
206 std::string title = generator_->generate(); 209 std::string title = generator_->generate();
207 210
208 // Want a 16:9 aspect 211 // Want a 16:9 aspect
@@ -316,7 +319,7 @@ void advice::run() const
316 client_->updateStatus(tweetText, {media_id}); 319 client_->updateStatus(tweetText, {media_id});
317 320
318 std::cout << "Tweeted!" << std::endl << "Waiting..." << std::endl; 321 std::cout << "Tweeted!" << std::endl << "Waiting..." << std::endl;
319 322
320 std::this_thread::sleep_for(std::chrono::hours(1)); 323 std::this_thread::sleep_for(std::chrono::hours(1));
321 } catch (const could_not_get_images& ex) 324 } catch (const could_not_get_images& ex)
322 { 325 {