From 4458cbab76fd98989fa2d4260dd20bbbd66297a4 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Mon, 6 Apr 2015 12:25:13 +0200 Subject: Switch back to libcurl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/libpiano/request.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/libpiano/request.c') 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 #include #include #include #include -/* needed for urlencode */ -#include #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)); -- cgit v1.2.3