From 1205c90cccd3144bab24b4b5fd8dcbf0d0e6b570 Mon Sep 17 00:00:00 2001 From: José Bollo Date: Thu, 31 Mar 2016 17:56:32 +0200 Subject: refactoring (in progress, tbf) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8f2684a38d0894d827510d9a171ee6d5c39fb55e Signed-off-by: José Bollo --- plugins/samples/HelloWorld.c | 5 +---- plugins/samples/SamplePost.c | 17 +++++------------ 2 files changed, 6 insertions(+), 16 deletions(-) (limited to 'plugins/samples') diff --git a/plugins/samples/HelloWorld.c b/plugins/samples/HelloWorld.c index 067365dd..6c2d0cf9 100644 --- a/plugins/samples/HelloWorld.c +++ b/plugins/samples/HelloWorld.c @@ -29,11 +29,8 @@ STATIC json_object* pingSample (AFB_request *request) { len = getQueryAll (request, query, sizeof(query)); if (len == 0) strcpy (query,"NoSearchQueryList"); - // check if we have some post data - if (request->post != NULL) request->post->data="NoData"; - // return response to caller - response = jsonNewMessage(AFB_SUCCESS, "Ping Binder Daemon %d query={%s} PostData: \'%s\' ", pingcount++, query, request->post); + response = jsonNewMessage(AFB_SUCCESS, "Ping Binder Daemon %d query={%s}", pingcount++, query); if (verbose) fprintf(stderr, "%d: \n", pingcount); return (response); diff --git a/plugins/samples/SamplePost.c b/plugins/samples/SamplePost.c index d29fb05a..24ee5385 100644 --- a/plugins/samples/SamplePost.c +++ b/plugins/samples/SamplePost.c @@ -23,38 +23,31 @@ static json_object* getPingTest(AFB_request *request) { static int pingcount = 0; json_object *response; - char query [256]; - char session[256]; + char query [8000]; int len; // request all query key/value len = getQueryAll (request, query, sizeof(query)); if (len == 0) strncpy (query, "NoSearchQueryList", sizeof(query)); - // check if we have some post data - if (request->post == NULL) request->post->data="NoData"; - // return response to caller - response = jsonNewMessage(AFB_SUCCESS, "Ping Binder Daemon count=%d uuid=%s query={%s} session={0x%x} PostData: [%s] " - , pingcount++, request->uuid, query, session, request->post->data); + response = jsonNewMessage(AFB_SUCCESS, "Ping Binder Daemon count=%d uuid=%s query={%s}" + , pingcount++, request->uuid, query); return (response); } // With content-type=json data are directly avaliable in request->post->data STATIC json_object* GetJsonByPost (AFB_request *request) { json_object* jresp; - char query [256]; + char query [8000]; int len; - // check if we have some post data - if (request->post == NULL) request->post->data="NoData"; - // Get all query string [Note real app should probably use value=getQueryValue(request,"key")] len = getQueryAll (request, query, sizeof(query)); if (len == 0) strncpy (query, "NoSearchQueryList", sizeof(query)); // for debug/test return response to caller - jresp = jsonNewMessage(AFB_SUCCESS, "GetJsonByPost query={%s} PostData: [%s]", query, request->post->data); + jresp = jsonNewMessage(AFB_SUCCESS, "GetJsonByPost query={%s}", query); return (jresp); } -- cgit 1.2.3-korg