提交 25926490 编写于 作者: X xywang

[TS-602]<enhance>: added HTTP header "Connection: close" if 4xx/5xx were returned

上级 3a93cbee
...@@ -147,7 +147,7 @@ typedef struct HttpContext { ...@@ -147,7 +147,7 @@ typedef struct HttpContext {
int32_t state; int32_t state;
uint8_t reqType; uint8_t reqType;
uint8_t parsed; uint8_t parsed;
uint8_t error; bool error;
char ipstr[22]; char ipstr[22];
char user[TSDB_USER_LEN]; // parsed from auth token or login message char user[TSDB_USER_LEN]; // parsed from auth token or login message
char pass[HTTP_PASSWORD_LEN]; char pass[HTTP_PASSWORD_LEN];
......
...@@ -120,6 +120,7 @@ HttpContext *httpCreateContext(SOCKET fd) { ...@@ -120,6 +120,7 @@ HttpContext *httpCreateContext(SOCKET fd) {
pContext->lastAccessTime = taosGetTimestampSec(); pContext->lastAccessTime = taosGetTimestampSec();
pContext->state = HTTP_CONTEXT_STATE_READY; pContext->state = HTTP_CONTEXT_STATE_READY;
pContext->parser = httpCreateParser(pContext); pContext->parser = httpCreateParser(pContext);
pContext->error = false;
TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE)pContext; TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE)pContext;
HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &handleVal, sizeof(TSDB_CACHE_PTR_TYPE), &pContext, HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &handleVal, sizeof(TSDB_CACHE_PTR_TYPE), &pContext,
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
const char *httpKeepAliveStr[] = {"", "Connection: Keep-Alive\r\n", "Connection: Close\r\n"}; const char *httpKeepAliveStr[] = {"", "Connection: Keep-Alive\r\n", "Connection: Close\r\n"};
const char *httpVersionStr[] = {"HTTP/1.0", "HTTP/1.1", "HTTP/1.2"}; const char *httpVersionStr[] = {"HTTP/1.0", "HTTP/1.1", "HTTP/2.0"}; /* There is no version 1.2 */
const char *httpRespTemplate[] = { const char *httpRespTemplate[] = {
// HTTP_RESPONSE_JSON_OK // HTTP_RESPONSE_JSON_OK
...@@ -52,8 +52,14 @@ static void httpSendErrorRespImp(HttpContext *pContext, int32_t httpCode, char * ...@@ -52,8 +52,14 @@ static void httpSendErrorRespImp(HttpContext *pContext, int32_t httpCode, char *
int8_t httpVersion = 0; int8_t httpVersion = 0;
int8_t keepAlive = 0; int8_t keepAlive = 0;
if (pContext->parser != NULL) { if (pContext->parser != NULL) {
httpVersion = pContext->parser->httpVersion; httpVersion = pContext->parser->httpVersion;
}
if (pContext->error == true) {
keepAlive = HTTP_KEEPALIVE_DISABLE;
} else if (pContext->parser != NULL) {
keepAlive = pContext->parser->keepAlive; keepAlive = pContext->parser->keepAlive;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册