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.
This commit is contained in:
YAMAMOTO Takashi 2022-03-07 09:30:23 +09:00 committed by Xiang Xiao
parent 7949059ec2
commit 092ce81444

View File

@ -245,6 +245,7 @@ static const char g_httpcrnl[] = "\r\n";
static const char g_httpform[] = "Content-Type: " static const char g_httpform[] = "Content-Type: "
"application/x-www-form-urlencoded"; "application/x-www-form-urlencoded";
static const char g_httpcontsize[] = "Content-Length: "; static const char g_httpcontsize[] = "Content-Length: ";
static const char g_httpconn_close[] = "Connection: close";
#if 0 #if 0
static const char g_httpconn[] = "Connection: Keep-Alive"; static const char g_httpconn[] = "Connection: Keep-Alive";
static const char g_httpcache[] = "Cache-Control: no-cache"; static const char g_httpcache[] = "Cache-Control: no-cache";
@ -1156,6 +1157,14 @@ int webclient_perform(FAR struct webclient_context *ctx)
dest = append(dest, ep, g_httpcrnl); 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); dest = append(dest, ep, g_httpuseragentfields);
if (dest == NULL) if (dest == NULL)