diff --git a/src/plugins/http/inc/httpInt.h b/src/plugins/http/inc/httpInt.h index bf8efd2831e19480615be291d409d53207bb8f63..af0f4c579557d1bd919847ef858af8dc1616bb6f 100644 --- a/src/plugins/http/inc/httpInt.h +++ b/src/plugins/http/inc/httpInt.h @@ -147,7 +147,7 @@ typedef struct HttpContext { int32_t state; uint8_t reqType; uint8_t parsed; - uint8_t error; + bool error; char ipstr[22]; char user[TSDB_USER_LEN]; // parsed from auth token or login message char pass[HTTP_PASSWORD_LEN]; diff --git a/src/plugins/http/src/httpContext.c b/src/plugins/http/src/httpContext.c index f26a4b4c8bdda05f801075b70c1b762882adfd27..4922d98ee492c94e56604d5823e87e4704ddf8e3 100644 --- a/src/plugins/http/src/httpContext.c +++ b/src/plugins/http/src/httpContext.c @@ -120,6 +120,7 @@ HttpContext *httpCreateContext(SOCKET fd) { pContext->lastAccessTime = taosGetTimestampSec(); pContext->state = HTTP_CONTEXT_STATE_READY; pContext->parser = httpCreateParser(pContext); + pContext->error = false; TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE)pContext; HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &handleVal, sizeof(TSDB_CACHE_PTR_TYPE), &pContext, diff --git a/src/plugins/http/src/httpResp.c b/src/plugins/http/src/httpResp.c index 1d05b455cb5c66e4f492140e1f337210da04caef..4065f881d1e8a8023e3adacfceaf243de60eebdc 100644 --- a/src/plugins/http/src/httpResp.c +++ b/src/plugins/http/src/httpResp.c @@ -52,8 +52,14 @@ static void httpSendErrorRespImp(HttpContext *pContext, int32_t httpCode, char * int8_t httpVersion = 0; int8_t keepAlive = 0; + if (pContext->parser != NULL) { httpVersion = pContext->parser->httpVersion; + } + + if (pContext->error == true) { + keepAlive = HTTP_KEEPALIVE_DISABLE; + } else if (pContext->parser != NULL) { keepAlive = pContext->parser->keepAlive; }