about summary refs log tree commit diff stats
path: root/src/stream.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2016-08-20 14:04:11 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2016-08-20 14:04:11 -0400
commit6c9f541f34c58ac817f88ffb5e069b929bbbc274 (patch)
treef493fbccbcdc1489b0ad58cd4b8587a3bf020bf4 /src/stream.cpp
parent69fc8d805396b889b5e8c1c88e8129d93db77d29 (diff)
parentc3cc76301d64320791f7097709ffcd36d7206266 (diff)
downloadlibtwittercpp-6c9f541f34c58ac817f88ffb5e069b929bbbc274.tar.gz
libtwittercpp-6c9f541f34c58ac817f88ffb5e069b929bbbc274.tar.bz2
libtwittercpp-6c9f541f34c58ac817f88ffb5e069b929bbbc274.zip
Merge branch 'master' of https://github.com/hatkirby/libtwittercpp
Diffstat (limited to 'src/stream.cpp')
-rw-r--r--src/stream.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/stream.cpp b/src/stream.cpp index 17dcce7..d2b3afe 100644 --- a/src/stream.cpp +++ b/src/stream.cpp
@@ -101,55 +101,55 @@ namespace twitter {
101 101
102 void stream::run(std::string url) 102 void stream::run(std::string url)
103 { 103 {
104 curl::curl_ios<stream> ios(this, [] (void* contents, size_t size, size_t nmemb, void* userp) { 104 _backoff_type = backoff::none;
105 return static_cast<stream*>(userp)->write(static_cast<char*>(contents), size, nmemb); 105 _backoff_amount = std::chrono::milliseconds(0);
106 }); 106 for (;;)
107 {
108 curl::curl_ios<stream> ios(this, [] (void* contents, size_t size, size_t nmemb, void* userp) {
109 return static_cast<stream*>(userp)->write(static_cast<char*>(contents), size, nmemb);
110 });
107 111
108 curl::curl_easy conn(ios); 112 curl::curl_easy conn(ios);
109 curl::curl_header headers; 113 curl::curl_header headers;
110 std::string oauth_header; 114 std::string oauth_header;
111 115
112 try 116 try
113 { 117 {
114 oauth_header = _client._oauth_client->getFormattedHttpHeader(OAuth::Http::Get, url, ""); 118 oauth_header = _client._oauth_client->getFormattedHttpHeader(OAuth::Http::Get, url, "");
115 119
116 if (!oauth_header.empty()) 120 if (!oauth_header.empty())
121 {
122 headers.add(oauth_header);
123 }
124 } catch (const OAuth::ParseError& error)
117 { 125 {
118 headers.add(oauth_header); 126 std::cout << "Error generating OAuth header:" << std::endl;
119 } 127 std::cout << error.what() << std::endl;
120 } catch (const OAuth::ParseError& error) 128 std::cout << "This is likely due to a malformed URL." << std::endl;
121 {
122 std::cout << "Error generating OAuth header:" << std::endl;
123 std::cout << error.what() << std::endl;
124 std::cout << "This is likely due to a malformed URL." << std::endl;
125 129
126 assert(false); 130 assert(false);
127 } 131 }
128 132
129 try 133 try
130 { 134 {
131 conn.add<CURLOPT_HEADERFUNCTION>(nullptr); 135 conn.add<CURLOPT_HEADERFUNCTION>(nullptr);
132 conn.add<CURLOPT_HEADERDATA>(nullptr); 136 conn.add<CURLOPT_HEADERDATA>(nullptr);
133 conn.add<CURLOPT_XFERINFOFUNCTION>([] (void* cdata, curl_off_t, curl_off_t, curl_off_t, curl_off_t) { 137 conn.add<CURLOPT_XFERINFOFUNCTION>([] (void* cdata, curl_off_t, curl_off_t, curl_off_t, curl_off_t) {
134 return static_cast<stream*>(cdata)->progress(); 138 return static_cast<stream*>(cdata)->progress();
135 }); 139 });
136 conn.add<CURLOPT_XFERINFODATA>(this); 140 conn.add<CURLOPT_XFERINFODATA>(this);
137 conn.add<CURLOPT_NOPROGRESS>(0); 141 conn.add<CURLOPT_NOPROGRESS>(0);
138 //conn.add<CURLOPT_VERBOSE>(1); 142 //conn.add<CURLOPT_VERBOSE>(1);
139 //conn.add<CURLOPT_DEBUGFUNCTION>(my_trace); 143 //conn.add<CURLOPT_DEBUGFUNCTION>(my_trace);
140 conn.add<CURLOPT_URL>(url.c_str()); 144 conn.add<CURLOPT_URL>(url.c_str());
141 conn.add<CURLOPT_HTTPHEADER>(headers.get()); 145 conn.add<CURLOPT_HTTPHEADER>(headers.get());
142 } catch (const curl::curl_exception& error) 146 } catch (const curl::curl_exception& error)
143 { 147 {
144 error.print_traceback(); 148 error.print_traceback();
149
150 assert(false);
151 }
145 152
146 assert(false);
147 }
148
149 _backoff_type = backoff::none;
150 _backoff_amount = std::chrono::milliseconds(0);
151 for (;;)
152 {
153 bool failure = false; 153 bool failure = false;
154 try 154 try
155 { 155 {