summaryrefslogtreecommitdiff
path: root/src/libpiano
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2015-04-06 12:25:13 +0200
committerLars-Dominik Braun <lars@6xq.net>2015-04-06 12:25:13 +0200
commit4458cbab76fd98989fa2d4260dd20bbbd66297a4 (patch)
tree832c7230129b50c278044cb9f4aabe711697ee69 /src/libpiano
parentb13b61b77b6d58c8b541bc4628b998681e94875f (diff)
downloadpianobar-4458cbab76fd98989fa2d4260dd20bbbd66297a4.tar.gz
pianobar-4458cbab76fd98989fa2d4260dd20bbbd66297a4.tar.bz2
pianobar-4458cbab76fd98989fa2d4260dd20bbbd66297a4.zip
Switch back to libcurl
Drops libwaitress. Adds the new dependency libcurl and drops gnutls. I wouldn’t say writing my own HTTP library was a mistake – it was not and the experience gained was worth it. Instead I have to acknowledge that libcurl is just better than my own implementation. Sure, it does a lot more than HTTP – one could call that bloat. Yet if you just want to get the job done™ reusing code is the way to go. See #512 and #513.
Diffstat (limited to 'src/libpiano')
-rw-r--r--src/libpiano/request.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/libpiano/request.c b/src/libpiano/request.c
index 6d0c8e5..cad0907 100644
--- a/src/libpiano/request.c
+++ b/src/libpiano/request.c
@@ -26,12 +26,11 @@ THE SOFTWARE.
#define _DARWIN_C_SOURCE /* strdup() on OS X */
#endif
+#include <curl/curl.h>
#include <json.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
-/* needed for urlencode */
-#include <waitress.h>
#include "piano.h"
#include "crypt.h"
@@ -100,13 +99,16 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
json_object_object_add (j, "syncTime",
json_object_new_int (timestamp));
- urlencAuthToken = WaitressUrlEncode (ph->partner.authToken);
+ CURL * const curl = curl_easy_init ();
+ urlencAuthToken = curl_easy_escape (curl,
+ ph->partner.authToken, 0);
assert (urlencAuthToken != NULL);
snprintf (req->urlPath, sizeof (req->urlPath),
PIANO_RPC_PATH "method=auth.userLogin&"
"auth_token=%s&partner_id=%i", urlencAuthToken,
ph->partner.id);
- free (urlencAuthToken);
+ curl_free (urlencAuthToken);
+ curl_easy_cleanup (curl);
break;
}
@@ -432,14 +434,17 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
assert (ph->user.authToken != NULL);
- urlencAuthToken = WaitressUrlEncode (ph->user.authToken);
+ CURL * const curl = curl_easy_init ();
+ urlencAuthToken = curl_easy_escape (curl,
+ ph->user.authToken, 0);
assert (urlencAuthToken != NULL);
snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH
"method=%s&auth_token=%s&partner_id=%i&user_id=%s", method,
urlencAuthToken, ph->partner.id, ph->user.listenerId);
- free (urlencAuthToken);
+ curl_free (urlencAuthToken);
+ curl_easy_cleanup (curl);
json_object_object_add (j, "userAuthToken",
json_object_new_string (ph->user.authToken));