You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/07/18 10:07:50 UTC

[GitHub] [incubator-nuttx-apps] xiaoxiang781216 commented on a change in pull request #333: webclient improvements

xiaoxiang781216 commented on a change in pull request #333:
URL: https://github.com/apache/incubator-nuttx-apps/pull/333#discussion_r456772641



##########
File path: include/netutils/webclient.h
##########
@@ -97,6 +97,140 @@
 typedef void (*wget_callback_t)(FAR char **buffer, int offset,
                                 int datend, FAR int *buflen, FAR void *arg);
 
+/* webclient_sink_callback_t: callback to consume data
+ *
+ * Same as wget_callback_t, but allowed to fail.
+ *
+ * Input Parameters:
+ *   Same as wget_callback_t
+ *
+ * Return value:
+ *   0 on success.
+ *   A negative errno on error.
+ */
+
+typedef CODE int (*webclient_sink_callback_t)(FAR char **buffer, int offset,

Review comment:
       Will you merge wget_callback_t and webclient_sink_callback_t into one finally?

##########
File path: include/netutils/webclient.h
##########
@@ -147,6 +281,12 @@ int wget(FAR const char *url, FAR char *buffer, int buflen,
 int wget_post(FAR const char *url, FAR const char *posts, FAR char *buffer,
               int buflen, wget_callback_t callback, FAR void *arg);
 
+void webclient_set_defaults(FAR struct webclient_context *ctx);

Review comment:
       Should we unify the prefix? either wget_xxx or webclient_xxx, but not both.

##########
File path: include/netutils/webclient.h
##########
@@ -97,6 +97,140 @@
 typedef void (*wget_callback_t)(FAR char **buffer, int offset,
                                 int datend, FAR int *buflen, FAR void *arg);
 
+/* webclient_sink_callback_t: callback to consume data
+ *
+ * Same as wget_callback_t, but allowed to fail.
+ *
+ * Input Parameters:
+ *   Same as wget_callback_t
+ *
+ * Return value:
+ *   0 on success.
+ *   A negative errno on error.
+ */
+
+typedef CODE int (*webclient_sink_callback_t)(FAR char **buffer, int offset,
+                                              int datend, FAR int *buflen,
+                                              FAR void *arg);
+
+/* webclient_body_callback_t: a callback to provide request body
+ *
+ * This callback can be called multiple times to provide
+ * webclient_context::bodylen bytes of the data.
+ * It's the responsibility of this callback to maintain the current
+ * "offset" of the data. (similarly to fread(3))
+ *
+ * An implementation of this callback should perform either of
+ * the followings:
+ *
+ * - fill the buffer (specified by buffer and *sizep) with the data
+ * - update *datap with a buffer filled with the data
+ *
+ * Either ways, it should update *sizep to the size of the data.
+ *
+ * A short result is allowed. In that case, this callback will be called
+ * again to provide the remaining data.
+ *
+ * Input Parameters:
+ *   buffer - The buffer to fill.
+ *   sizep  - The size of buffer/data in bytes.
+ *   datap  - The data to return.

Review comment:
       Why need datap if we already has buffer?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org