- static int postcount = 0; // static counter to debug POST protocol
- char *baseurl, *baseapi, *urlcpy1, *urlcpy2, *query, *token, *uuid;
- json_object *errMessage;
- AFB_error status;
- struct MHD_Response *webResponse;
- const char *serialized, parsedurl;
- AFB_request request;
- AFB_HttpPost *posthandle = *con_cls;
- AFB_clientCtx clientCtx;
- int idx, ret;
+ // retrieve API request from Post iterator handle
+ AFB_PostHandle *postctx = (AFB_PostHandle*)cls;
+ AFB_request *request = (AFB_request*)post->private;
+ AFB_PostRequest post;
+
+
+ // Create and Item value for Plugin API
+ item.kind = kind;
+ item.key = key;
+ item.filename = filename;
+ item.mimetype = mimetype;
+ item.encoding = encoding;
+ item.len = size;
+ item.data = data;
+ item.off = off;
+
+ // Reformat Request to make it somehow similar to GET/PostJson case
+ post.data= (char*) postctx;
+ post.len = size;
+ post.type= AFB_POST_FORM;;
+ request->post = &post;
+
+ // effectively call plugin API
+ status = findAndCallApi (request, &item);
+
+ // when returning no processing of postform stop
+ if (status != AFB_SUCCESS) return MHD_NO;
+
+ // let's allow iterator to move to next item
+ return (MHD_YES;);
+}
+
+STATIC void freeRequest (AFB_request *request) {
+ free (request->plugin);
+ free (request->api);
+ free (request);
+}