about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/client.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/client.cpp b/src/client.cpp index b7d1624..51c288d 100644 --- a/src/client.cpp +++ b/src/client.cpp
@@ -661,7 +661,6 @@ namespace twitter {
661 661
662 void client::stream::run() 662 void client::stream::run()
663 { 663 {
664 curl::curl_easy conn;
665 std::ostringstream urlstr; 664 std::ostringstream urlstr;
666 urlstr << "https://userstream.twitter.com/1.1/user.json"; 665 urlstr << "https://userstream.twitter.com/1.1/user.json";
667 666
@@ -671,29 +670,31 @@ namespace twitter {
671 } 670 }
672 671
673 std::string url = urlstr.str(); 672 std::string url = urlstr.str();
674 curl::curl_header headers;
675 std::string oauth_header = _client._oauth_client->getFormattedHttpHeader(OAuth::Http::Get, url, "");
676 if (!oauth_header.empty())
677 {
678 headers.add(oauth_header);
679 }
680
681 conn.add<CURLOPT_WRITEFUNCTION>(client_stream_write_callback_wrapper);
682 conn.add<CURLOPT_WRITEDATA>(this);
683 conn.add<CURLOPT_HEADERFUNCTION>(nullptr);
684 conn.add<CURLOPT_HEADERDATA>(nullptr);
685 conn.add<CURLOPT_XFERINFOFUNCTION>(client_stream_progress_callback_wrapper);
686 conn.add<CURLOPT_XFERINFODATA>(this);
687 conn.add<CURLOPT_NOPROGRESS>(0);
688 //conn.add<CURLOPT_VERBOSE>(1);
689 //conn.add<CURLOPT_DEBUGFUNCTION>(my_trace);
690 conn.add<CURLOPT_URL>(url.c_str());
691 conn.add<CURLOPT_HTTPHEADER>(headers.get());
692 673
693 _backoff_type = backoff::none; 674 _backoff_type = backoff::none;
694 _backoff_amount = std::chrono::milliseconds(0); 675 _backoff_amount = std::chrono::milliseconds(0);
695 for (;;) 676 for (;;)
696 { 677 {
678 curl::curl_easy conn;
679 curl::curl_header headers;
680 std::string oauth_header = _client._oauth_client->getFormattedHttpHeader(OAuth::Http::Get, url, "");
681 if (!oauth_header.empty())
682 {
683 headers.add(oauth_header);
684 }
685
686 conn.add<CURLOPT_WRITEFUNCTION>(client_stream_write_callback_wrapper);
687 conn.add<CURLOPT_WRITEDATA>(this);
688 conn.add<CURLOPT_HEADERFUNCTION>(nullptr);
689 conn.add<CURLOPT_HEADERDATA>(nullptr);
690 conn.add<CURLOPT_XFERINFOFUNCTION>(client_stream_progress_callback_wrapper);
691 conn.add<CURLOPT_XFERINFODATA>(this);
692 conn.add<CURLOPT_NOPROGRESS>(0);
693 //conn.add<CURLOPT_VERBOSE>(1);
694 //conn.add<CURLOPT_DEBUGFUNCTION>(my_trace);
695 conn.add<CURLOPT_URL>(url.c_str());
696 conn.add<CURLOPT_HTTPHEADER>(headers.get());
697
697 bool failure = false; 698 bool failure = false;
698 try { 699 try {
699 conn.perform(); 700 conn.perform();