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:07 UTC
[incubator-nuttx-apps] 03/04: webclient: Always use "connection: close" for HTTP 1.1 for now
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 092ce8144445a9b287554e59e3150bab3d67bedb
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Mon Mar 7 09:30:23 2022 +0900
webclient: Always use "connection: close" for HTTP 1.1 for now
* This matches the HTTP 1.0 behavior.
* Persistent connection doesn't make much sense with the current API.
---
netutils/webclient/webclient.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/netutils/webclient/webclient.c b/netutils/webclient/webclient.c
index 5b07bac..fe5ffc1 100644
--- a/netutils/webclient/webclient.c
+++ b/netutils/webclient/webclient.c
@@ -240,14 +240,15 @@ static const char g_httpuseragentfields[] =
CONFIG_NSH_WGET_USERAGENT
"\r\n\r\n";
-static const char g_httpcrnl[] = "\r\n";
+static const char g_httpcrnl[] = "\r\n";
-static const char g_httpform[] = "Content-Type: "
- "application/x-www-form-urlencoded";
-static const char g_httpcontsize[] = "Content-Length: ";
+static const char g_httpform[] = "Content-Type: "
+ "application/x-www-form-urlencoded";
+static const char g_httpcontsize[] = "Content-Length: ";
+static const char g_httpconn_close[] = "Connection: close";
#if 0
-static const char g_httpconn[] = "Connection: Keep-Alive";
-static const char g_httpcache[] = "Cache-Control: no-cache";
+static const char g_httpconn[] = "Connection: Keep-Alive";
+static const char g_httpcache[] = "Cache-Control: no-cache";
#endif
/****************************************************************************
@@ -1156,6 +1157,14 @@ int webclient_perform(FAR struct webclient_context *ctx)
dest = append(dest, ep, g_httpcrnl);
}
+ if (ctx->protocol_version == WEBCLIENT_PROTOCOL_VERSION_HTTP_1_1)
+ {
+ /* We don't implement persistect connections. */
+
+ dest = append(dest, ep, g_httpconn_close);
+ dest = append(dest, ep, g_httpcrnl);
+ }
+
dest = append(dest, ep, g_httpuseragentfields);
if (dest == NULL)