You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/03/08 01:44:05 UTC

[incubator-nuttx-apps] 01/04: webclient: Add a parameter to specifiy protocol version

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 3759da3d00697cd80c4e1d90790063b867379710
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Mon Mar 7 09:29:17 2022 +0900

    webclient: Add a parameter to specifiy protocol version
---
 include/netutils/webclient.h   | 7 +++++++
 netutils/webclient/webclient.c | 1 +
 2 files changed, 8 insertions(+)

diff --git a/include/netutils/webclient.h b/include/netutils/webclient.h
index 560f04c..1d69f71 100644
--- a/include/netutils/webclient.h
+++ b/include/netutils/webclient.h
@@ -307,6 +307,7 @@ struct webclient_context
 {
   /* request parameters
    *
+   *   protocol_version - HTTP protocol version. HTTP 1.0 by default.
    *   method           - HTTP method like "GET", "POST".
    *                      The default value is "GET".
    *   url              - A pointer to a string containing the full URL.
@@ -325,6 +326,12 @@ struct webclient_context
    *                      10 seconds by default.
    */
 
+  enum webclient_protocol_version_e
+    {
+      WEBCLIENT_PROTOCOL_VERSION_HTTP_1_0, /* HTTP 1.0 */
+      WEBCLIENT_PROTOCOL_VERSION_HTTP_1_1, /* HTTP 1.1 */
+    } protocol_version;
+
   FAR const char *method;
   FAR const char *url;
 #if defined(CONFIG_WEBCLIENT_NET_LOCAL)
diff --git a/netutils/webclient/webclient.c b/netutils/webclient/webclient.c
index 570f622..df1cd8f 100644
--- a/netutils/webclient/webclient.c
+++ b/netutils/webclient/webclient.c
@@ -1625,6 +1625,7 @@ int wget_post(FAR const char *url, FAR const char *posts, FAR char *buffer,
 void webclient_set_defaults(FAR struct webclient_context *ctx)
 {
   memset(ctx, 0, sizeof(*ctx));
+  ctx->protocol_version = WEBCLIENT_PROTOCOL_VERSION_HTTP_1_0;
   ctx->method = "GET";
   ctx->timeout_sec = CONFIG_WEBCLIENT_TIMEOUT;
   _SET_STATE(ctx, WEBCLIENT_CONTEXT_STATE_INITIALIZED);