Active --dry-run for OAuth.
authorgregor herrmann <gregoa@debian.org>
Sun, 2 Jan 2011 00:31:29 +0000 (01:31 +0100)
committergregor herrmann <gregoa@debian.org>
Sun, 2 Jan 2011 00:34:08 +0000 (01:34 +0100)
Guard the oauth_http_post/_get with an '!session->dry_run'
conditional, and add a dbg() statement before.

http://bugs.debian.org/608608

bti.c

diff --git a/bti.c b/bti.c
index 0229a9a..26d7928 100644 (file)
--- a/bti.c
+++ b/bti.c
@@ -749,26 +749,29 @@ static int send_request(struct session *session)
                        break;
                }
 
-               if (is_post) {
-                       req_url = oauth_sign_url2(endpoint, &postarg, OA_HMAC,
-                                                 NULL, session->consumer_key,
-                                                 session->consumer_secret,
-                                                 session->access_token_key,
-                                                 session->access_token_secret);
-                       reply = oauth_http_post(req_url, postarg);
-               } else {
-                       req_url = oauth_sign_url2(endpoint, NULL, OA_HMAC, NULL,
-                                                 session->consumer_key,
-                                                 session->consumer_secret,
-                                                 session->access_token_key,
-                                                 session->access_token_secret);
-                       reply = oauth_http_get(req_url, postarg);
-               }
+               dbg("%s\n", endpoint);
+               if (!session->dry_run) {
+                       if (is_post) {
+                               req_url = oauth_sign_url2(endpoint, &postarg, OA_HMAC,
+                                                         NULL, session->consumer_key,
+                                                         session->consumer_secret,
+                                                         session->access_token_key,
+                                                         session->access_token_secret);
+                               reply = oauth_http_post(req_url, postarg);
+                       } else {
+                               req_url = oauth_sign_url2(endpoint, NULL, OA_HMAC, NULL,
+                                                         session->consumer_key,
+                                                         session->consumer_secret,
+                                                         session->access_token_key,
+                                                         session->access_token_secret);
+                               reply = oauth_http_get(req_url, postarg);
+                       }
 
-               dbg("%s\n", req_url);
-               dbg("%s\n", reply);
-               if (req_url)
-                       free(req_url);
+                       dbg("%s\n", req_url);
+                       dbg("%s\n", reply);
+                       if (req_url)
+                               free(req_url);
+               }
 
                if ((session->action != ACTION_UPDATE) &&
                                (session->action != ACTION_RETWEET))