about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/client.cpp b/src/client.cpp index 1b32b8b..2c655e2 100644 --- a/src/client.cpp +++ b/src/client.cpp
@@ -743,7 +743,6 @@ namespace twitter {
743 743
744 void client::stream::run() 744 void client::stream::run()
745 { 745 {
746 curl::curl_easy conn;
747 std::ostringstream urlstr; 746 std::ostringstream urlstr;
748 urlstr << "https://userstream.twitter.com/1.1/user.json"; 747 urlstr << "https://userstream.twitter.com/1.1/user.json";
749 748
@@ -753,29 +752,31 @@ namespace twitter {
753 } 752 }
754 753
755 std::string url = urlstr.str(); 754 std::string url = urlstr.str();
756 curl::curl_header headers;
757 std::string oauth_header = _client._oauth_client->getFormattedHttpHeader(OAuth::Http::Get, url, "");
758 if (!oauth_header.empty())
759 {
760 headers.add(oauth_header);
761 }
762
763 conn.add<CURLOPT_WRITEFUNCTION>(client_stream_write_callback_wrapper);
764 conn.add<CURLOPT_WRITEDATA>(this);
765 conn.add<CURLOPT_HEADERFUNCTION>(nullptr);
766 conn.add<CURLOPT_HEADERDATA>(nullptr);
767 conn.add<CURLOPT_XFERINFOFUNCTION>(client_stream_progress_callback_wrapper);
768 conn.add<CURLOPT_XFERINFODATA>(this);
769 conn.add<CURLOPT_NOPROGRESS>(0);
770 //conn.add<CURLOPT_VERBOSE>(1);
771 //conn.add<CURLOPT_DEBUGFUNCTION>(my_trace);
772 conn.add<CURLOPT_URL>(url.c_str());
773 conn.add<CURLOPT_HTTPHEADER>(headers.get());
774 755
775 _backoff_type = backoff::none; 756 _backoff_type = backoff::none;
776 _backoff_amount = std::chrono::milliseconds(0); 757 _backoff_amount = std::chrono::milliseconds(0);
777 for (;;) 758 for (;;)
778 { 759 {
760 curl::curl_easy conn;
761 curl::curl_header headers;
762 std::string oauth_header = _client._oauth_client->getFormattedHttpHeader(OAuth::Http::Get, url, "");
763 if (!oauth_header.empty())
764 {
765 headers.add(oauth_header);
766 }
767
768 conn.add<CURLOPT_WRITEFUNCTION>(client_stream_write_callback_wrapper);
769 conn.add<CURLOPT_WRITEDATA>(this);
770 conn.add<CURLOPT_HEADERFUNCTION>(nullptr);
771 conn.add<CURLOPT_HEADERDATA>(nullptr);
772 conn.add<CURLOPT_XFERINFOFUNCTION>(client_stream_progress_callback_wrapper);
773 conn.add<CURLOPT_XFERINFODATA>(this);
774 conn.add<CURLOPT_NOPROGRESS>(0);
775 //conn.add<CURLOPT_VERBOSE>(1);
776 //conn.add<CURLOPT_DEBUGFUNCTION>(my_trace);
777 conn.add<CURLOPT_URL>(url.c_str());
778 conn.add<CURLOPT_HTTPHEADER>(headers.get());
779
779 bool failure = false; 780 bool failure = false;
780 try { 781 try {
781 conn.perform(); 782 conn.perform();