Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7dd32d26
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7dd32d26
编写于
9月 14, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1311
上级
eff4b580
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
260 addition
and
461 deletion
+260
-461
src/inc/taoserror.h
src/inc/taoserror.h
+98
-31
src/plugins/http/inc/httpCode.h
src/plugins/http/inc/httpCode.h
+0
-112
src/plugins/http/inc/httpInt.h
src/plugins/http/inc/httpInt.h
+1
-2
src/plugins/http/inc/httpResp.h
src/plugins/http/inc/httpResp.h
+0
-2
src/plugins/http/src/httpCode.c
src/plugins/http/src/httpCode.c
+0
-108
src/plugins/http/src/httpGcHandle.c
src/plugins/http/src/httpGcHandle.c
+9
-8
src/plugins/http/src/httpGcJson.c
src/plugins/http/src/httpGcJson.c
+13
-13
src/plugins/http/src/httpJson.c
src/plugins/http/src/httpJson.c
+0
-1
src/plugins/http/src/httpParser.c
src/plugins/http/src/httpParser.c
+1
-1
src/plugins/http/src/httpResp.c
src/plugins/http/src/httpResp.c
+82
-130
src/plugins/http/src/httpRestHandle.c
src/plugins/http/src/httpRestHandle.c
+5
-4
src/plugins/http/src/httpServer.c
src/plugins/http/src/httpServer.c
+1
-1
src/plugins/http/src/httpSession.c
src/plugins/http/src/httpSession.c
+2
-1
src/plugins/http/src/httpSql.c
src/plugins/http/src/httpSql.c
+8
-7
src/plugins/http/src/httpTgHandle.c
src/plugins/http/src/httpTgHandle.c
+40
-40
未找到文件。
src/inc/taoserror.h
浏览文件 @
7dd32d26
...
...
@@ -248,37 +248,104 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_ENABLED, 0, 0x0901, "Sync modul
TAOS_DEFINE_ERROR
(
TSDB_CODE_WAL_APP_ERROR
,
0
,
0x1000
,
"Unexpected generic error in wal"
)
// http
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_UNSUPPORT_URL
,
0
,
0x1100
,
"http url is not support"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_NO_ENOUGH_MEMORY
,
0
,
0x1101
,
"no enough memory"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_INVALID_VERSION
,
0
,
0x1102
,
"invalid http version"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_INVALID_CONTENT_LENGTH
,
0
,
0x1103
,
"invalid content length"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_CREATE_GZIP_FAILED
,
0
,
0x1104
,
"failed to create gzip"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_FINISH_GZIP_FAILED
,
0
,
0x1105
,
"failed to finish gzip"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_INVALID_AUTH_TYPE
,
0
,
0x1106
,
"invalid type of Authorization"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_INVALID_AUTH_FORMAT
,
0
,
0x1107
,
"invalid format of Authorization"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_INVALID_BASIC_AUTH
,
0
,
0x1108
,
"invalid basic Authorization"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_INVALID_TAOSD_AUTH
,
0
,
0x1109
,
"invalid taosd Authorization"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_METHOD_FAILED
,
0
,
0x110A
,
"failed to parse method"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_TARGET_FAILED
,
0
,
0x110B
,
"failed to parse target"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_VERSION_FAILED
,
0
,
0x110C
,
"failed to parse http version"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_SP_FAILED
,
0
,
0x110D
,
"failed to parse sp"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_STATUS_FAILED
,
0
,
0x110E
,
"failed to parse status"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_PHRASE_FAILED
,
0
,
0x110F
,
"failed to parse phrase"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_CRLF_FAILED
,
0
,
0x1110
,
"failed to parse crlf"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_HEADER_FAILED
,
0
,
0x1111
,
"failed to parse header"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_HEADER_KEY_FAILED
,
0
,
0x1112
,
"failed to parse header key"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_HEADER_VAL_FAILED
,
0
,
0x1113
,
"failed to parse header val"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_CHUNK_SIZE_FAILED
,
0
,
0x1114
,
"failed to parse chunk size"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_CHUNK_FAILED
,
0
,
0x1115
,
"failed to parse chunk"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_END_FAILED
,
0
,
0x1116
,
"failed to parse end section"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_INVALID_STATE
,
0
,
0x1117
,
"invalid parse state"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_ERROR_STATE
,
0
,
0x1118
,
"failed to parse error section"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_SERVER_OFFLINE
,
0
,
0x1100
,
"http server is not onlin"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_UNSUPPORT_URL
,
0
,
0x1101
,
"url is not support"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_INVLALID_URL
,
0
,
0x1102
,
"invalid url format"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_NO_ENOUGH_MEMORY
,
0
,
0x1103
,
"no enough memory"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_REQUSET_TOO_BIG
,
0
,
0x1104
,
"request size is too big"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_NO_AUTH_INFO
,
0
,
0x1105
,
"no auth info input"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_NO_MSG_INPUT
,
0
,
0x1106
,
"request is empty"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_NO_SQL_INPUT
,
0
,
0x1107
,
"no sql input"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_NO_EXEC_USEDB
,
0
,
0x1108
,
"no need to execute use db cmd"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_SESSION_FULL
,
0
,
0x1109
,
"session list was full"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_GEN_TAOSD_TOKEN_ERR
,
0
,
0x110A
,
"generate taosd token error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_INVALID_MULTI_REQUEST
,
0
,
0x110B
,
"size of multi request is 0"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_CREATE_GZIP_FAILED
,
0
,
0x110C
,
"failed to create gzip"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_FINISH_GZIP_FAILED
,
0
,
0x110D
,
"failed to finish gzip"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_LOGIN_FAILED
,
0
,
0x110E
,
"failed to login"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_INVALID_VERSION
,
0
,
0x1120
,
"invalid http version"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_INVALID_CONTENT_LENGTH
,
0
,
0x1121
,
"invalid content length"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_INVALID_AUTH_TYPE
,
0
,
0x1122
,
"invalid type of Authorization"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_INVALID_AUTH_FORMAT
,
0
,
0x1123
,
"invalid format of Authorization"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_INVALID_BASIC_AUTH
,
0
,
0x1124
,
"invalid basic Authorization"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_INVALID_TAOSD_AUTH
,
0
,
0x1125
,
"invalid taosd Authorization"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_METHOD_FAILED
,
0
,
0x1126
,
"failed to parse method"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_TARGET_FAILED
,
0
,
0x1127
,
"failed to parse target"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_VERSION_FAILED
,
0
,
0x1128
,
"failed to parse http version"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_SP_FAILED
,
0
,
0x1129
,
"failed to parse sp"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_STATUS_FAILED
,
0
,
0x112A
,
"failed to parse status"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_PHRASE_FAILED
,
0
,
0x112B
,
"failed to parse phrase"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_CRLF_FAILED
,
0
,
0x112C
,
"failed to parse crlf"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_HEADER_FAILED
,
0
,
0x112D
,
"failed to parse header"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_HEADER_KEY_FAILED
,
0
,
0x112E
,
"failed to parse header key"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_HEADER_VAL_FAILED
,
0
,
0x112F
,
"failed to parse header val"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_CHUNK_SIZE_FAILED
,
0
,
0x1130
,
"failed to parse chunk size"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_CHUNK_FAILED
,
0
,
0x1131
,
"failed to parse chunk"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_END_FAILED
,
0
,
0x1132
,
"failed to parse end section"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_INVALID_STATE
,
0
,
0x1134
,
"invalid parse state"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_PARSE_ERROR_STATE
,
0
,
0x1135
,
"failed to parse error section"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_GC_QUERY_NULL
,
0
,
0x1150
,
"query size is 0"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_GC_QUERY_SIZE
,
0
,
0x1151
,
"query size can not more than 100"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_GC_REQ_PARSE_ERROR
,
0
,
0x1152
,
"parse grafana json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_DB_NOT_INPUT
,
0
,
0x1160
,
"database name can not be null"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_DB_TOO_LONG
,
0
,
0x1161
,
"database name too long"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_INVALID_JSON
,
0
,
0x1162
,
"invalid telegraf json fromat"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_METRICS_NULL
,
0
,
0x1163
,
"metrics size is 0"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_METRICS_SIZE
,
0
,
0x1164
,
"metrics size can not more than 1K"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_METRIC_NULL
,
0
,
0x1165
,
"metric name not find"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_METRIC_TYPE
,
0
,
0x1166
,
"metric name type should be string"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_METRIC_NAME_NULL
,
0
,
0x1167
,
"metric name length is 0"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_METRIC_NAME_LONG
,
0
,
0x1168
,
"metric name length too long"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_TIMESTAMP_NULL
,
0
,
0x1169
,
"timestamp not find"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_TIMESTAMP_TYPE
,
0
,
0x116A
,
"timestamp type should be integer"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_TIMESTAMP_VAL_NULL
,
0
,
0x116B
,
"timestamp value smaller than 0"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_TAGS_NULL
,
0
,
0x116C
,
"tags not find"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_TAGS_SIZE_0
,
0
,
0x116D
,
"tags size too long"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_TAGS_SIZE_LONG
,
0
,
0x116E
,
"tags size is 0"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_TAG_NULL
,
0
,
0x116F
,
"tag is null"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_TAG_NAME_NULL
,
0
,
0x1170
,
"tag name is null"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_TAG_NAME_SIZE
,
0
,
0x1171
,
"tag name length too long"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_TAG_VALUE_TYPE
,
0
,
0x1172
,
"tag value type should be number or string"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_TAG_VALUE_NULL
,
0
,
0x1173
,
"tag value is null"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_TABLE_NULL
,
0
,
0x1174
,
"table is null"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_TABLE_SIZE
,
0
,
0x1175
,
"table name length too long"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_FIELDS_NULL
,
0
,
0x1176
,
"fields not find"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_FIELDS_SIZE_0
,
0
,
0x1177
,
"fields size is 0"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_FIELDS_SIZE_LONG
,
0
,
0x1178
,
"fields size too long"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_FIELD_NULL
,
0
,
0x1179
,
"field is null"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_FIELD_NAME_NULL
,
0
,
0x117A
,
"field name is null"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_FIELD_NAME_SIZE
,
0
,
0x117B
,
"field name length too long"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_FIELD_VALUE_TYPE
,
0
,
0x117C
,
"field value type should be number or string"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_FIELD_VALUE_NULL
,
0
,
0x117D
,
"field value is null"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_HOST_NOT_STRING
,
0
,
0x117E
,
"host type should be string"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_TG_STABLE_NOT_EXIST
,
0
,
0x117F
,
"stable not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_DB_NOT_INPUT
,
0
,
0x1190
,
"database name can not be null"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_DB_TOO_LONG
,
0
,
0x1191
,
"database name too long"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_INVALID_JSON
,
0
,
0x1192
,
"invalid opentsdb json fromat"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_METRICS_NULL
,
0
,
0x1193
,
"metrics size is 0"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_METRICS_SIZE
,
0
,
0x1194
,
"metrics size can not more than 10K"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_METRIC_NULL
,
0
,
0x1195
,
"metric name not find"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_METRIC_TYPE
,
0
,
0x1196
,
"metric name type should be string"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_METRIC_NAME_NULL
,
0
,
0x1197
,
"metric name length is 0"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_METRIC_NAME_LONG
,
0
,
0x1198
,
"metric name length can not more than 22"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_TIMESTAMP_NULL
,
0
,
0x1199
,
"timestamp not find"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_TIMESTAMP_TYPE
,
0
,
0x119A
,
"timestamp type should be integer"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_TIMESTAMP_VAL_NULL
,
0
,
0x119B
,
"timestamp value smaller than 0"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_TAGS_NULL
,
0
,
0x119C
,
"tags not find"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_TAGS_SIZE_0
,
0
,
0x119D
,
"tags size is 0"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_TAGS_SIZE_LONG
,
0
,
0x119E
,
"tags size too long"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_TAG_NULL
,
0
,
0x119F
,
"tag is null"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_TAG_NAME_NULL
,
0
,
0x11A0
,
"tag name is null"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_TAG_NAME_SIZE
,
0
,
0x11A1
,
"tag name length too long"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_TAG_VALUE_TYPE
,
0
,
0x11A2
,
"tag value type should be boolean, number or string"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_TAG_VALUE_NULL
,
0
,
0x11A3
,
"tag value is null"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_TAG_VALUE_TOO_LONG
,
0
,
0x11A4
,
"tag value can not more than 64"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_VALUE_NULL
,
0
,
0x11A5
,
"value not find"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_VALUE_TYPE
,
0
,
0x11A5
,
"value type should be boolean, number or string"
)
#ifdef TAOS_ERROR_C
};
...
...
src/plugins/http/inc/httpCode.h
已删除
100644 → 0
浏览文件 @
eff4b580
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_HTTP_CODE_H
#define TDENGINE_HTTP_CODE_H
//for fixed msg info
#define HTTP_SUCCESS 0
#define HTTP_SERVER_OFFLINE 1
#define HTTP_UNSUPPORT_URL 2
#define HTTP_PARSE_HTTP_METHOD_ERROR 3
#define HTTP_PARSE_HTTP_VERSION_ERROR 4
#define HTTP_PARSE_HEAD_ERROR 5
#define HTTP_REQUSET_TOO_BIG 6
#define HTTP_PARSE_BODY_ERROR 7
#define HTTP_PARSE_CHUNKED_BODY_ERROR 8
#define HTTP_PARSE_URL_ERROR 9
#define HTTP_INVALID_AUTH_TOKEN 10
#define HTTP_PARSE_USR_ERROR 11
#define HTTP_NO_SQL_INPUT 12
#define HTTP_SESSION_FULL 13
#define HTTP_NO_ENOUGH_MEMORY 14
#define HTTP_GEN_TAOSD_TOKEN_ERR 15
#define HTTP_INVALID_DB_TABLE 16
#define HTTP_NO_EXEC_USEDB 17
#define HTTP_PARSE_GC_REQ_ERROR 18
#define HTTP_INVALID_MULTI_REQUEST 19
#define HTTP_NO_MSG_INPUT 20
#define HTTP_NO_ENOUGH_SESSIONS 21
//telegraf
#define HTTP_TG_DB_NOT_INPUT 22
#define HTTP_TG_DB_TOO_LONG 23
#define HTTP_TG_INVALID_JSON 24
#define HTTP_TG_METRICS_NULL 25
#define HTTP_TG_METRICS_SIZE 26
#define HTTP_TG_METRIC_NULL 27
#define HTTP_TG_METRIC_TYPE 28
#define HTTP_TG_METRIC_NAME_NULL 29
#define HTTP_TG_METRIC_NAME_LONG 30
#define HTTP_TG_TIMESTAMP_NULL 31
#define HTTP_TG_TIMESTAMP_TYPE 32
#define HTTP_TG_TIMESTAMP_VAL_NULL 33
#define HTTP_TG_TAGS_NULL 34
#define HTTP_TG_TAGS_SIZE_0 35
#define HTTP_TG_TAGS_SIZE_LONG 36
#define HTTP_TG_TAG_NULL 37
#define HTTP_TG_TAG_NAME_NULL 38
#define HTTP_TG_TAG_NAME_SIZE 39
#define HTTP_TG_TAG_VALUE_TYPE 40
#define HTTP_TG_TAG_VALUE_NULL 41
#define HTTP_TG_TABLE_NULL 42
#define HTTP_TG_TABLE_SIZE 43
#define HTTP_TG_FIELDS_NULL 44
#define HTTP_TG_FIELDS_SIZE_0 45
#define HTTP_TG_FIELDS_SIZE_LONG 46
#define HTTP_TG_FIELD_NULL 47
#define HTTP_TG_FIELD_NAME_NULL 48
#define HTTP_TG_FIELD_NAME_SIZE 49
#define HTTP_TG_FIELD_VALUE_TYPE 50
#define HTTP_TG_FIELD_VALUE_NULL 51
#define HTTP_INVALID_BASIC_AUTH_TOKEN 52
#define HTTP_INVALID_TAOSD_AUTH_TOKEN 53
#define HTTP_TG_HOST_NOT_STRING 54
//grafana
#define HTTP_GC_QUERY_NULL 55
#define HTTP_GC_QUERY_SIZE 56
//opentsdb
#define HTTP_OP_DB_NOT_INPUT 57
#define HTTP_OP_DB_TOO_LONG 58
#define HTTP_OP_INVALID_JSON 59
#define HTTP_OP_METRICS_NULL 60
#define HTTP_OP_METRICS_SIZE 61
#define HTTP_OP_METRIC_NULL 62
#define HTTP_OP_METRIC_TYPE 63
#define HTTP_OP_METRIC_NAME_NULL 64
#define HTTP_OP_METRIC_NAME_LONG 65
#define HTTP_OP_TIMESTAMP_NULL 66
#define HTTP_OP_TIMESTAMP_TYPE 67
#define HTTP_OP_TIMESTAMP_VAL_NULL 68
#define HTTP_OP_TAGS_NULL 69
#define HTTP_OP_TAGS_SIZE_0 70
#define HTTP_OP_TAGS_SIZE_LONG 71
#define HTTP_OP_TAG_NULL 72
#define HTTP_OP_TAG_NAME_NULL 73
#define HTTP_OP_TAG_NAME_SIZE 74
#define HTTP_OP_TAG_VALUE_TYPE 75
#define HTTP_OP_TAG_VALUE_NULL 76
#define HTTP_OP_TAG_VALUE_TOO_LONG 77
#define HTTP_OP_VALUE_NULL 78
#define HTTP_OP_VALUE_TYPE 79
//tgf
#define HTTP_TG_STABLE_NOT_EXIST 80
extern
char
*
httpMsg
[];
#endif
\ No newline at end of file
src/plugins/http/inc/httpInt.h
浏览文件 @
7dd32d26
...
...
@@ -24,7 +24,6 @@
#include "tutil.h"
#include "zlib.h"
#include "http.h"
#include "httpCode.h"
#include "httpLog.h"
#include "httpJson.h"
#include "httpParser.h"
...
...
@@ -37,7 +36,7 @@
#define HTTP_BUFFER_SIZE 8192000
#define HTTP_STEP_SIZE 1024 //http message get process step by step
#define HTTP_METHOD_SCANNER_SIZE 7 //http method fp size
#define HTTP_GC_TARGET_SIZE 512
#define
TSDB_CODE_
HTTP_GC_TARGET_SIZE 512
#define HTTP_WRITE_RETRY_TIMES 500
#define HTTP_WRITE_WAIT_TIME_MS 5
#define HTTP_SESSION_ID_LEN (TSDB_USER_LEN + TSDB_PASSWORD_LEN)
...
...
src/plugins/http/inc/httpResp.h
浏览文件 @
7dd32d26
...
...
@@ -33,8 +33,6 @@ enum _httpRespTempl {
extern
const
char
*
httpRespTemplate
[];
void
httpSendErrorResp
(
HttpContext
*
pContext
,
int32_t
errNo
);
void
httpSendErrorRespWithDesc
(
HttpContext
*
pContext
,
int32_t
errNo
,
char
*
desc
);
void
httpSendTaosdErrorResp
(
HttpContext
*
pContext
,
int32_t
errCode
);
void
httpSendTaosdInvalidSqlErrorResp
(
HttpContext
*
pContext
,
char
*
errMsg
);
void
httpSendSuccResp
(
HttpContext
*
pContext
,
char
*
desc
);
void
httpSendOptionResp
(
HttpContext
*
pContext
,
char
*
desc
);
...
...
src/plugins/http/src/httpCode.c
已删除
100644 → 0
浏览文件 @
eff4b580
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
char
*
httpMsg
[]
=
{
"success"
,
// 0
"http server is not online"
,
// 1
"http url is not support"
,
// 2
"http method parse error"
,
// 3
"http version should be 1.0, 1.1 or 1.2"
,
// 4
"http head parse error"
,
// 5
"request size is too big"
,
"http body size invalid"
,
"http chunked body parse error"
,
// 8
"http url parse error"
,
// 9
"invalid type of Authorization"
,
"no auth info input"
,
"no sql input"
,
"session list was full"
,
"no enough memory to alloc sqls"
,
"generate taosd token error"
,
"db and table can not be null"
,
"no need to execute use db cmd"
,
"parse grafana json error"
,
"size of multi request is 0"
,
// 19
"request is empty"
,
// 20
"no enough connections for http"
,
// 21
// telegraf
"database name can not be null"
,
// 22
"database name too long"
,
"invalid telegraf json fromat"
,
"metrics size is 0"
,
"metrics size can not more than 1K"
,
// 26
"metric name not find"
,
"metric name type should be string"
,
"metric name length is 0"
,
"metric name length too long"
,
"timestamp not find"
,
// 31
"timestamp type should be integer"
,
"timestamp value smaller than 0"
,
"tags not find"
,
"tags size is 0"
,
"tags size too long"
,
// 36
"tag is null"
,
"tag name is null"
,
"tag name length too long"
,
// 39
"tag value type should be number or string"
,
"tag value is null"
,
"table is null"
,
// 42
"table name length too long"
,
"fields not find"
,
// 44
"fields size is 0"
,
"fields size too long"
,
"field is null"
,
// 47
"field name is null"
,
"field name length too long"
,
// 49
"field value type should be number or string"
,
"field value is null"
,
// 51
"parse basic auth token error"
,
"parse http auth token error"
,
"host type should be string"
,
// grafana
"query size is 0"
,
// 55
"query size can not more than 100"
,
// opentsdb
"database name can not be null"
,
// 57
"database name too long"
,
"invalid opentsdb json fromat"
,
// 59
"metrics size is 0"
,
"metrics size can not more than 10K"
,
// 61
"metric name not find"
,
"metric name type should be string"
,
"metric name length is 0"
,
"metric name length can not more than 22"
,
"timestamp not find"
,
"timestamp type should be integer"
,
"timestamp value smaller than 0"
,
"tags not find"
,
"tags size is 0"
,
"tags size too long"
,
// 71
"tag is null"
,
"tag name is null"
,
"tag name length too long"
,
// 74
"tag value type should be boolean, number or string"
,
"tag value is null"
,
"tag value can not more than 64"
,
// 77
"value not find"
,
"value type should be boolean, number or string"
,
"stable not exist"
,
};
src/plugins/http/src/httpGcHandle.c
浏览文件 @
7dd32d26
...
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "taoserror.h"
#include "cJSON.h"
#include "httpLog.h"
#include "httpGcHandle.h"
...
...
@@ -146,31 +147,31 @@ bool gcProcessQueryRequest(HttpContext* pContext) {
char
*
filter
=
pContext
->
parser
->
body
.
str
;
if
(
filter
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_NO_MSG_INPUT
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_NO_MSG_INPUT
);
return
false
;
}
cJSON
*
root
=
cJSON_Parse
(
filter
);
if
(
root
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_PARSE_GC_REQ
_ERROR
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_HTTP_GC_REQ_PARSE
_ERROR
);
return
false
;
}
int32_t
size
=
cJSON_GetArraySize
(
root
);
if
(
size
<=
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_GC_QUERY_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_GC_QUERY_NULL
);
cJSON_Delete
(
root
);
return
false
;
}
if
(
size
>
100
)
{
httpSendErrorResp
(
pContext
,
HTTP_GC_QUERY_SIZE
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_GC_QUERY_SIZE
);
cJSON_Delete
(
root
);
return
false
;
}
if
(
!
httpMallocMultiCmds
(
pContext
,
size
,
HTTP_BUFFER_SIZE
))
{
httpSendErrorResp
(
pContext
,
HTTP_NO_ENOUGH_MEMORY
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_NO_ENOUGH_MEMORY
);
cJSON_Delete
(
root
);
return
false
;
}
...
...
@@ -218,7 +219,7 @@ bool gcProcessQueryRequest(HttpContext* pContext) {
HttpSqlCmd
*
cmd
=
httpNewSqlCmd
(
pContext
);
if
(
cmd
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_NO_ENOUGH_MEMORY
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_NO_ENOUGH_MEMORY
);
cJSON_Delete
(
root
);
return
false
;
}
...
...
@@ -227,7 +228,7 @@ bool gcProcessQueryRequest(HttpContext* pContext) {
cmd
->
values
=
refIdBuffer
;
cmd
->
table
=
aliasBuffer
;
cmd
->
numOfRows
=
0
;
// hack way as target flags
cmd
->
timestamp
=
httpAddToSqlCmdBufferWithSize
(
pContext
,
HTTP_GC_TARGET_SIZE
+
1
);
// hack way
cmd
->
timestamp
=
httpAddToSqlCmdBufferWithSize
(
pContext
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
+
1
);
// hack way
if
(
cmd
->
timestamp
==
-
1
)
{
httpWarn
(
"context:%p, fd:%d, user:%s, cant't malloc target size, sql buffer is full"
,
pContext
,
pContext
->
fd
,
...
...
@@ -260,7 +261,7 @@ bool gcProcessRequest(struct HttpContext* pContext) {
}
if
(
strlen
(
pContext
->
user
)
==
0
||
strlen
(
pContext
->
pass
)
==
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_PARSE_USR_ERROR
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_HTTP_NO_AUTH_INFO
);
return
false
;
}
...
...
src/plugins/http/src/httpGcJson.c
浏览文件 @
7dd32d26
...
...
@@ -129,48 +129,48 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
// for group by
if
(
groupFields
!=
-
1
)
{
char
target
[
HTTP_GC_TARGET_SIZE
]
=
{
0
};
char
target
[
TSDB_CODE_
HTTP_GC_TARGET_SIZE
]
=
{
0
};
int32_t
len
;
len
=
snprintf
(
target
,
HTTP_GC_TARGET_SIZE
,
"%s{"
,
aliasBuffer
);
len
=
snprintf
(
target
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
,
"%s{"
,
aliasBuffer
);
for
(
int32_t
i
=
dataFields
+
1
;
i
<
num_fields
;
i
++
){
switch
(
fields
[
i
].
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%d"
,
fields
[
i
].
name
,
*
((
int8_t
*
)
row
[
i
]));
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%d"
,
fields
[
i
].
name
,
*
((
int8_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%d"
,
fields
[
i
].
name
,
*
((
int16_t
*
)
row
[
i
]));
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%d"
,
fields
[
i
].
name
,
*
((
int16_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_INT
:
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%d,"
,
fields
[
i
].
name
,
*
((
int32_t
*
)
row
[
i
]));
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%d,"
,
fields
[
i
].
name
,
*
((
int32_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_BIGINT
:
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%ld"
,
fields
[
i
].
name
,
*
((
int64_t
*
)
row
[
i
]));
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%ld"
,
fields
[
i
].
name
,
*
((
int64_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_FLOAT
:
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%.5f"
,
fields
[
i
].
name
,
*
((
float
*
)
row
[
i
]));
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%.5f"
,
fields
[
i
].
name
,
*
((
float
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%.9f"
,
fields
[
i
].
name
,
*
((
double
*
)
row
[
i
]));
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%.9f"
,
fields
[
i
].
name
,
*
((
double
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
if
(
row
[
i
]
!=
NULL
){
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:"
,
fields
[
i
].
name
);
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:"
,
fields
[
i
].
name
);
memcpy
(
target
+
len
,
(
char
*
)
row
[
i
],
length
[
i
]);
len
=
strlen
(
target
);
}
break
;
default:
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%s"
,
fields
[
i
].
name
,
"-"
);
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%s"
,
fields
[
i
].
name
,
"-"
);
break
;
}
if
(
i
<
num_fields
-
1
){
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
", "
);
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
", "
);
}
}
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"}"
);
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"}"
);
if
(
strcmp
(
target
,
targetBuffer
)
!=
0
)
{
// first target not write this section
...
...
@@ -180,7 +180,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
// start new target
gcWriteTargetStartJson
(
jsonBuf
,
refIdBuffer
,
target
);
strncpy
(
targetBuffer
,
target
,
HTTP_GC_TARGET_SIZE
);
strncpy
(
targetBuffer
,
target
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
);
}
}
// end of group by
...
...
src/plugins/http/src/httpJson.c
浏览文件 @
7dd32d26
...
...
@@ -20,7 +20,6 @@
#include "tglobal.h"
#include "http.h"
#include "httpLog.h"
#include "httpCode.h"
#include "httpJson.h"
#include "httpResp.h"
#include "httpUtil.h"
...
...
src/plugins/http/src/httpParser.c
浏览文件 @
7dd32d26
...
...
@@ -338,7 +338,7 @@ static int32_t httpOnBody(HttpParser *parser, const char *chunk, int32_t len) {
if
(
len
+
1
>=
avail
)
{
if
(
buf
->
size
>=
HTTP_BUFFER_SIZE
)
{
httpError
(
"context:%p, fd:%d, failed parse body, exceeding buffer size %d"
,
pContext
,
pContext
->
fd
,
buf
->
size
);
httpOnError
(
parser
,
0
,
TSDB_CODE_HTTP_
NO_ENOUGH_MEMORY
);
httpOnError
(
parser
,
0
,
TSDB_CODE_HTTP_
REQUSET_TOO_BIG
);
return
-
1
;
}
else
{
int32_t
newSize
=
buf
->
size
*
10
;
...
...
src/plugins/http/src/httpResp.c
浏览文件 @
7dd32d26
...
...
@@ -19,7 +19,6 @@
#include "taosmsg.h"
#include "httpLog.h"
#include "httpResp.h"
#include "httpCode.h"
#include "httpJson.h"
#include "httpContext.h"
...
...
@@ -45,7 +44,7 @@ const char *httpRespTemplate[] = {
"%s 200 OK
\r\n
Access-Control-Allow-Origin:*
\r\n
%sAccess-Control-Allow-Methods:POST, GET, OPTIONS, DELETE, PUT
\r\n
Access-Control-Allow-Headers:Accept, Content-Type
\r\n
Content-Type: application/json;charset=utf-8
\r\n
Content-Length: %d
\r\n\r\n
"
};
static
void
httpSendErrorRespImp
(
HttpContext
*
pContext
,
int32_t
httpCode
,
char
*
httpCodeStr
,
int32_t
errNo
,
char
*
desc
)
{
static
void
httpSendErrorRespImp
(
HttpContext
*
pContext
,
int32_t
httpCode
,
char
*
httpCodeStr
,
int32_t
errNo
,
c
onst
c
har
*
desc
)
{
httpError
(
"context:%p, fd:%d, code:%d, error:%s"
,
pContext
,
pContext
->
fd
,
httpCode
,
desc
);
char
head
[
512
]
=
{
0
};
...
...
@@ -60,132 +59,85 @@ static void httpSendErrorRespImp(HttpContext *pContext, int32_t httpCode, char *
httpCloseContextByApp
(
pContext
);
}
void
httpSendErrorRespWithDesc
(
HttpContext
*
pContext
,
int32_t
errNo
,
char
*
desc
)
{
int32_t
httpCode
=
500
;
char
*
httpCodeStr
=
"Internal Server Error"
;
switch
(
errNo
)
{
case
HTTP_SUCCESS
:
httpCode
=
200
;
httpCodeStr
=
"OK"
;
break
;
case
HTTP_SERVER_OFFLINE
:
case
HTTP_UNSUPPORT_URL
:
httpCode
=
404
;
httpCodeStr
=
"Not Found"
;
break
;
case
HTTP_PARSE_HTTP_METHOD_ERROR
:
httpCode
=
405
;
httpCodeStr
=
"Method Not Allowed"
;
break
;
case
HTTP_PARSE_HTTP_VERSION_ERROR
:
httpCode
=
505
;
httpCodeStr
=
"HTTP Version Not Supported"
;
break
;
case
HTTP_PARSE_HEAD_ERROR
:
httpCode
=
406
;
httpCodeStr
=
"Not Acceptable"
;
break
;
case
HTTP_REQUSET_TOO_BIG
:
httpCode
=
413
;
httpCodeStr
=
"Request Entity Too Large"
;
break
;
case
HTTP_PARSE_BODY_ERROR
:
case
HTTP_PARSE_CHUNKED_BODY_ERROR
:
httpCode
=
409
;
httpCodeStr
=
"Conflict"
;
break
;
case
HTTP_PARSE_URL_ERROR
:
httpCode
=
414
;
httpCodeStr
=
"Request-URI Invalid"
;
break
;
case
HTTP_INVALID_AUTH_TOKEN
:
case
HTTP_PARSE_USR_ERROR
:
httpCode
=
401
;
httpCodeStr
=
"Unauthorized"
;
break
;
case
HTTP_NO_SQL_INPUT
:
httpCode
=
400
;
httpCodeStr
=
"Bad Request"
;
break
;
case
HTTP_SESSION_FULL
:
httpCode
=
421
;
httpCodeStr
=
"Too many connections"
;
break
;
case
HTTP_NO_ENOUGH_MEMORY
:
case
HTTP_GEN_TAOSD_TOKEN_ERR
:
httpCode
=
507
;
httpCodeStr
=
"Insufficient Storage"
;
break
;
case
HTTP_INVALID_DB_TABLE
:
case
HTTP_NO_EXEC_USEDB
:
case
HTTP_PARSE_GC_REQ_ERROR
:
case
HTTP_INVALID_MULTI_REQUEST
:
case
HTTP_NO_MSG_INPUT
:
httpCode
=
400
;
httpCodeStr
=
"Bad Request"
;
break
;
case
HTTP_NO_ENOUGH_SESSIONS
:
httpCode
=
421
;
httpCodeStr
=
"Too many connections"
;
break
;
// telegraf
case
HTTP_TG_DB_NOT_INPUT
:
case
HTTP_TG_DB_TOO_LONG
:
case
HTTP_TG_INVALID_JSON
:
case
HTTP_TG_METRICS_NULL
:
case
HTTP_TG_METRICS_SIZE
:
case
HTTP_TG_METRIC_NULL
:
case
HTTP_TG_METRIC_TYPE
:
case
HTTP_TG_METRIC_NAME_NULL
:
case
HTTP_TG_METRIC_NAME_LONG
:
case
HTTP_TG_TIMESTAMP_NULL
:
case
HTTP_TG_TIMESTAMP_TYPE
:
case
HTTP_TG_TIMESTAMP_VAL_NULL
:
case
HTTP_TG_TAGS_NULL
:
case
HTTP_TG_TAGS_SIZE_0
:
case
HTTP_TG_TAGS_SIZE_LONG
:
case
HTTP_TG_TAG_NULL
:
case
HTTP_TG_TAG_NAME_NULL
:
case
HTTP_TG_TAG_NAME_SIZE
:
case
HTTP_TG_TAG_VALUE_TYPE
:
case
HTTP_TG_TAG_VALUE_NULL
:
case
HTTP_TG_TABLE_NULL
:
case
HTTP_TG_TABLE_SIZE
:
case
HTTP_TG_FIELDS_NULL
:
case
HTTP_TG_FIELDS_SIZE_0
:
case
HTTP_TG_FIELDS_SIZE_LONG
:
case
HTTP_TG_FIELD_NULL
:
case
HTTP_TG_FIELD_NAME_NULL
:
case
HTTP_TG_FIELD_NAME_SIZE
:
case
HTTP_TG_FIELD_VALUE_TYPE
:
case
HTTP_TG_FIELD_VALUE_NULL
:
case
HTTP_INVALID_BASIC_AUTH_TOKEN
:
case
HTTP_INVALID_TAOSD_AUTH_TOKEN
:
case
HTTP_TG_HOST_NOT_STRING
:
// grafana
case
HTTP_GC_QUERY_NULL
:
case
HTTP_GC_QUERY_SIZE
:
httpCode
=
400
;
httpCodeStr
=
"Bad Request"
;
break
;
default:
httpError
(
"context:%p, fd:%d, error:%d not recognized"
,
pContext
,
pContext
->
fd
,
errNo
);
break
;
}
if
(
desc
==
NULL
)
{
httpSendErrorRespImp
(
pContext
,
httpCode
,
httpCodeStr
,
errNo
+
5000
,
httpMsg
[
errNo
]);
}
else
{
httpSendErrorRespImp
(
pContext
,
httpCode
,
httpCodeStr
,
errNo
+
5000
,
desc
);
}
}
void
httpSendErrorResp
(
HttpContext
*
pContext
,
int32_t
errNo
)
{
httpSendErrorRespWithDesc
(
pContext
,
errNo
,
NULL
);
}
void
httpSendTaosdErrorResp
(
HttpContext
*
pContext
,
int32_t
errCode
)
{
int32_t
httpCode
=
400
;
httpSendErrorRespImp
(
pContext
,
httpCode
,
"Bad Request"
,
errCode
&
0XFFFF
,
(
char
*
)
tstrerror
(
errCode
));
void
httpSendErrorResp
(
HttpContext
*
pContext
,
int32_t
errNo
)
{
int32_t
httpCode
=
500
;
if
(
errNo
==
TSDB_CODE_SUCCESS
)
httpCode
=
200
;
else
if
(
errNo
==
TSDB_CODE_HTTP_SERVER_OFFLINE
)
httpCode
=
404
;
else
if
(
errNo
==
TSDB_CODE_HTTP_UNSUPPORT_URL
)
httpCode
=
404
;
else
if
(
errNo
==
TSDB_CODE_HTTP_INVLALID_URL
)
httpCode
=
404
;
else
if
(
errNo
==
TSDB_CODE_HTTP_NO_ENOUGH_MEMORY
)
httpCode
=
507
;
else
if
(
errNo
==
TSDB_CODE_HTTP_REQUSET_TOO_BIG
)
httpCode
=
413
;
else
if
(
errNo
==
TSDB_CODE_HTTP_NO_AUTH_INFO
)
httpCode
=
401
;
else
if
(
errNo
==
TSDB_CODE_HTTP_NO_MSG_INPUT
)
httpCode
=
400
;
else
if
(
errNo
==
TSDB_CODE_HTTP_NO_SQL_INPUT
)
httpCode
=
400
;
else
if
(
errNo
==
TSDB_CODE_HTTP_NO_EXEC_USEDB
)
httpCode
=
400
;
else
if
(
errNo
==
TSDB_CODE_HTTP_SESSION_FULL
)
httpCode
=
421
;
else
if
(
errNo
==
TSDB_CODE_HTTP_GEN_TAOSD_TOKEN_ERR
)
httpCode
=
507
;
else
if
(
errNo
==
TSDB_CODE_HTTP_INVALID_MULTI_REQUEST
)
httpCode
=
400
;
else
if
(
errNo
==
TSDB_CODE_HTTP_CREATE_GZIP_FAILED
)
httpCode
=
507
;
else
if
(
errNo
==
TSDB_CODE_HTTP_FINISH_GZIP_FAILED
)
httpCode
=
507
;
else
if
(
errNo
==
TSDB_CODE_HTTP_INVALID_VERSION
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_INVALID_CONTENT_LENGTH
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_INVALID_AUTH_TYPE
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_INVALID_AUTH_FORMAT
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_INVALID_BASIC_AUTH
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_INVALID_TAOSD_AUTH
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_METHOD_FAILED
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_TARGET_FAILED
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_VERSION_FAILED
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_SP_FAILED
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_STATUS_FAILED
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_PHRASE_FAILED
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_CRLF_FAILED
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_HEADER_FAILED
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_HEADER_KEY_FAILED
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_HEADER_VAL_FAILED
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_CHUNK_SIZE_FAILED
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_CHUNK_FAILED
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_END_FAILED
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_INVALID_STATE
)
httpCode
=
406
;
else
if
(
errNo
==
TSDB_CODE_HTTP_PARSE_ERROR_STATE
)
httpCode
=
406
;
else
httpCode
=
400
;
char
*
httpCodeStr
=
httpGetStatusDesc
(
httpCode
);
httpSendErrorRespImp
(
pContext
,
httpCode
,
httpCodeStr
,
errNo
&
0XFFFF
,
tstrerror
(
errNo
));
}
void
httpSendTaosdInvalidSqlErrorResp
(
HttpContext
*
pContext
,
char
*
errMsg
)
{
...
...
@@ -208,7 +160,7 @@ void httpSendSuccResp(HttpContext *pContext, char *desc) {
char
head
[
1024
]
=
{
0
};
char
body
[
1024
]
=
{
0
};
int32_t
bodyLen
=
sprintf
(
body
,
httpRespTemplate
[
HTTP_RESPONSE_JSON_OK
],
HTTP
_SUCCESS
,
desc
);
int32_t
bodyLen
=
sprintf
(
body
,
httpRespTemplate
[
HTTP_RESPONSE_JSON_OK
],
TSDB_CODE
_SUCCESS
,
desc
);
int32_t
headLen
=
sprintf
(
head
,
httpRespTemplate
[
HTTP_RESPONSE_OK
],
httpVersionStr
[
pContext
->
parser
->
httpVersion
],
httpKeepAliveStr
[
pContext
->
parser
->
keepAlive
],
bodyLen
);
...
...
@@ -221,7 +173,7 @@ void httpSendOptionResp(HttpContext *pContext, char *desc) {
char
head
[
1024
]
=
{
0
};
char
body
[
1024
]
=
{
0
};
int32_t
bodyLen
=
sprintf
(
body
,
httpRespTemplate
[
HTTP_RESPONSE_JSON_OK
],
HTTP
_SUCCESS
,
desc
);
int32_t
bodyLen
=
sprintf
(
body
,
httpRespTemplate
[
HTTP_RESPONSE_JSON_OK
],
TSDB_CODE
_SUCCESS
,
desc
);
int32_t
headLen
=
sprintf
(
head
,
httpRespTemplate
[
HTTP_RESPONSE_OPTIONS
],
httpVersionStr
[
pContext
->
parser
->
httpVersion
],
httpKeepAliveStr
[
pContext
->
parser
->
keepAlive
],
bodyLen
);
...
...
src/plugins/http/src/httpRestHandle.c
浏览文件 @
7dd32d26
...
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "httpLog.h"
#include "httpRestHandle.h"
#include "httpRestJson.h"
...
...
@@ -90,7 +91,7 @@ bool restProcessSqlRequest(HttpContext* pContext, int32_t timestampFmt) {
char
*
sql
=
pContext
->
parser
->
body
.
str
;
if
(
sql
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_NO_SQL_INPUT
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_NO_SQL_INPUT
);
return
false
;
}
...
...
@@ -99,7 +100,7 @@ bool restProcessSqlRequest(HttpContext* pContext, int32_t timestampFmt) {
* for async test
*
if (httpCheckUsedbSql(sql)) {
httpSendErrorResp(pContext, HTTP_NO_EXEC_USEDB);
httpSendErrorResp(pContext,
TSDB_CODE_
HTTP_NO_EXEC_USEDB);
return false;
}
*/
...
...
@@ -126,7 +127,7 @@ bool restProcessRequest(struct HttpContext* pContext) {
}
if
(
strlen
(
pContext
->
user
)
==
0
||
strlen
(
pContext
->
pass
)
==
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_PARSE_USR_ERROR
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_HTTP_NO_AUTH_INFO
);
return
false
;
}
...
...
@@ -141,6 +142,6 @@ bool restProcessRequest(struct HttpContext* pContext) {
}
else
{
}
httpSendErrorResp
(
pContext
,
HTTP_PARSE_URL_ERROR
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_HTTP_INVLALID_URL
);
return
false
;
}
src/plugins/http/src/httpServer.c
浏览文件 @
7dd32d26
...
...
@@ -139,7 +139,7 @@ static void httpProcessHttpData(void *param) {
if
(
pServer
->
status
!=
HTTP_SERVER_RUNNING
)
{
httpDebug
(
"context:%p, fd:%d, state:%s, server is not running, accessed:%d, close connect"
,
pContext
,
pContext
->
fd
,
httpContextStateStr
(
pContext
->
state
),
pContext
->
accessTimes
);
httpSendErrorResp
(
pContext
,
HTTP_SERVER_OFFLINE
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_SERVER_OFFLINE
);
httpNotifyContextClose
(
pContext
);
}
else
{
if
(
httpReadData
(
pContext
))
{
...
...
src/plugins/http/src/httpSession.c
浏览文件 @
7dd32d26
...
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taos.h"
#include "taoserror.h"
#include "tglobal.h"
#include "tcache.h"
#include "httpInt.h"
...
...
@@ -40,7 +41,7 @@ void httpCreateSession(HttpContext *pContext, void *taos) {
if
(
pContext
->
session
==
NULL
)
{
httpError
(
"context:%p, fd:%d, user:%s, error:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
user
,
httpMsg
[
HTTP_SESSION_FULL
]
);
tstrerror
(
TSDB_CODE_HTTP_SESSION_FULL
)
);
taos_close
(
taos
);
pthread_mutex_unlock
(
&
server
->
serverMutex
);
return
;
...
...
src/plugins/http/src/httpSql.c
浏览文件 @
7dd32d26
...
...
@@ -17,6 +17,7 @@
#include "os.h"
#include "tnote.h"
#include "taos.h"
#include "taoserror.h"
#include "tsclient.h"
#include "httpInt.h"
#include "httpContext.h"
...
...
@@ -193,7 +194,7 @@ void httpProcessMultiSqlCmd(HttpContext *pContext) {
HttpSqlCmds
*
multiCmds
=
pContext
->
multiCmds
;
if
(
multiCmds
==
NULL
||
multiCmds
->
size
<=
0
||
multiCmds
->
pos
>=
multiCmds
->
size
||
multiCmds
->
pos
<
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_INVALID_MULTI_REQUEST
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_INVALID_MULTI_REQUEST
);
return
;
}
...
...
@@ -282,7 +283,7 @@ void httpProcessSingleSqlCallBackImp(void *param, TAOS_RES *result, int unUsedCo
}
else
{
httpError
(
"context:%p, fd:%d, user:%s, query error, taos:%p, code:%s, sqlObj:%p"
,
pContext
,
pContext
->
fd
,
pContext
->
user
,
pContext
->
session
->
taos
,
tstrerror
(
code
),
pObj
);
httpSend
Taosd
ErrorResp
(
pContext
,
code
);
httpSendErrorResp
(
pContext
,
code
);
}
taos_free_result
(
result
);
return
;
...
...
@@ -332,7 +333,7 @@ void httpProcessSingleSqlCmd(HttpContext *pContext) {
if
(
sql
==
NULL
||
sql
[
0
]
==
0
)
{
httpError
(
"context:%p, fd:%d, user:%s, error:no sql input"
,
pContext
,
pContext
->
fd
,
pContext
->
user
);
httpSendErrorResp
(
pContext
,
HTTP_NO_SQL_INPUT
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_NO_SQL_INPUT
);
return
;
}
...
...
@@ -344,7 +345,7 @@ void httpProcessSingleSqlCmd(HttpContext *pContext) {
void
httpProcessLoginCmd
(
HttpContext
*
pContext
)
{
char
token
[
128
]
=
{
0
};
if
(
!
httpGenTaosdAuthToken
(
pContext
,
token
,
128
))
{
httpSendErrorResp
(
pContext
,
HTTP_GEN_TAOSD_TOKEN_ERR
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_GEN_TAOSD_TOKEN_ERR
);
}
else
{
httpDebug
(
"context:%p, fd:%d, user:%s, login via http, return token:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
user
,
token
);
...
...
@@ -395,7 +396,7 @@ void httpProcessRequestCb(void *param, TAOS_RES *result, int code) {
if
(
code
<
0
)
{
httpError
(
"context:%p, fd:%d, user:%s, login error, code:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
user
,
tstrerror
(
code
));
httpSend
Taosd
ErrorResp
(
pContext
,
code
);
httpSendErrorResp
(
pContext
,
code
);
return
;
}
...
...
@@ -403,14 +404,14 @@ void httpProcessRequestCb(void *param, TAOS_RES *result, int code) {
pContext
->
taos
);
if
(
pContext
->
taos
==
NULL
)
{
httpError
(
"context:%p, fd:%d, user:%s, login error, taos is empty"
,
pContext
,
pContext
->
fd
,
pContext
->
user
);
httpSendErrorResp
(
pContext
,
HTTP_NO_ENOUGH_SESSIONS
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_HTTP_LOGIN_FAILED
);
return
;
}
httpCreateSession
(
pContext
,
pContext
->
taos
);
if
(
pContext
->
session
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_SESSION_FULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_SESSION_FULL
);
httpCloseContextByApp
(
pContext
);
}
else
{
httpExecCmd
(
pContext
);
...
...
src/plugins/http/src/httpTgHandle.c
浏览文件 @
7dd32d26
...
...
@@ -335,12 +335,12 @@ bool tgGetPassFromUrl(HttpContext *pContext) {
char
*
tgGetDbFromUrl
(
HttpContext
*
pContext
)
{
HttpParser
*
pParser
=
pContext
->
parser
;
if
(
pParser
->
path
[
TG_DB_URL_POS
].
pos
<=
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_DB_NOT_INPUT
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_DB_NOT_INPUT
);
return
NULL
;
}
if
(
pParser
->
path
[
TG_DB_URL_POS
].
pos
>=
TSDB_DB_NAME_LEN
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_DB_TOO_LONG
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_DB_TOO_LONG
);
return
NULL
;
}
...
...
@@ -401,57 +401,57 @@ bool tgProcessSingleMetric(HttpContext *pContext, cJSON *metric, char *db) {
// metric name
cJSON
*
name
=
cJSON_GetObjectItem
(
metric
,
"name"
);
if
(
name
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_METRIC_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_METRIC_NULL
);
return
false
;
}
if
(
name
->
type
!=
cJSON_String
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_METRIC_TYPE
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_METRIC_TYPE
);
return
false
;
}
if
(
name
->
valuestring
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_METRIC_NAME_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_METRIC_NAME_NULL
);
return
false
;
}
int32_t
nameLen
=
(
int32_t
)
strlen
(
name
->
valuestring
);
if
(
nameLen
==
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_METRIC_NAME_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_METRIC_NAME_NULL
);
return
false
;
}
if
(
nameLen
>=
TSDB_TABLE_NAME_LEN
-
8
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_METRIC_NAME_LONG
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_METRIC_NAME_LONG
);
return
false
;
}
// timestamp
cJSON
*
timestamp
=
cJSON_GetObjectItem
(
metric
,
"timestamp"
);
if
(
timestamp
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_TIMESTAMP_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_TIMESTAMP_NULL
);
return
false
;
}
if
(
timestamp
->
type
!=
cJSON_Number
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_TIMESTAMP_TYPE
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_TIMESTAMP_TYPE
);
return
false
;
}
if
(
timestamp
->
valueint
<=
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_TIMESTAMP_VAL_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_TIMESTAMP_VAL_NULL
);
return
false
;
}
// tags
cJSON
*
tags
=
cJSON_GetObjectItem
(
metric
,
"tags"
);
if
(
tags
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_TAGS_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_TAGS_NULL
);
return
false
;
}
int32_t
tagsSize
=
cJSON_GetArraySize
(
tags
);
if
(
tagsSize
<=
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_TAGS_SIZE_0
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_TAGS_SIZE_0
);
return
false
;
}
if
(
tagsSize
>
TG_MAX_SORT_TAG_SIZE
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_TAGS_SIZE_LONG
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_TAGS_SIZE_LONG
);
return
false
;
}
...
...
@@ -460,11 +460,11 @@ bool tgProcessSingleMetric(HttpContext *pContext, cJSON *metric, char *db) {
for
(
int32_t
i
=
0
;
i
<
tagsSize
;
i
++
)
{
cJSON
*
tag
=
cJSON_GetArrayItem
(
tags
,
i
);
if
(
tag
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_TAG_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_TAG_NULL
);
return
false
;
}
if
(
tag
->
string
==
NULL
||
strlen
(
tag
->
string
)
==
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_TAG_NAME_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_TAG_NAME_NULL
);
return
false
;
}
...
...
@@ -474,19 +474,19 @@ bool tgProcessSingleMetric(HttpContext *pContext, cJSON *metric, char *db) {
*/
if
(
0
)
{
if
(
strlen
(
tag
->
string
)
>=
TSDB_COL_NAME_LEN
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_TAG_NAME_SIZE
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_TAG_NAME_SIZE
);
return
false
;
}
}
if
(
tag
->
type
!=
cJSON_Number
&&
tag
->
type
!=
cJSON_String
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_TAG_VALUE_TYPE
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_TAG_VALUE_TYPE
);
return
false
;
}
if
(
tag
->
type
==
cJSON_String
)
{
if
(
tag
->
valuestring
==
NULL
||
strlen
(
tag
->
valuestring
)
==
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_TAG_VALUE_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_TAG_VALUE_NULL
);
return
false
;
}
}
...
...
@@ -497,46 +497,46 @@ bool tgProcessSingleMetric(HttpContext *pContext, cJSON *metric, char *db) {
}
if
(
host
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_TABLE_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_TABLE_NULL
);
return
false
;
}
if
(
host
->
type
!=
cJSON_String
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_HOST_NOT_STRING
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_HOST_NOT_STRING
);
return
false
;
}
if
(
strlen
(
host
->
valuestring
)
>=
TSDB_TABLE_NAME_LEN
-
1
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_TABLE_SIZE
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_TABLE_SIZE
);
return
false
;
}
// fields
cJSON
*
fields
=
cJSON_GetObjectItem
(
metric
,
"fields"
);
if
(
fields
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_FIELDS_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_FIELDS_NULL
);
return
false
;
}
int32_t
fieldsSize
=
cJSON_GetArraySize
(
fields
);
if
(
fieldsSize
<=
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_FIELDS_SIZE_0
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_FIELDS_SIZE_0
);
return
false
;
}
if
(
fieldsSize
>
(
TSDB_MAX_COLUMNS
-
TSDB_MAX_TAGS
-
1
))
{
httpSendErrorResp
(
pContext
,
HTTP_TG_FIELDS_SIZE_LONG
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_FIELDS_SIZE_LONG
);
return
false
;
}
for
(
int32_t
i
=
0
;
i
<
fieldsSize
;
i
++
)
{
cJSON
*
field
=
cJSON_GetArrayItem
(
fields
,
i
);
if
(
field
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_FIELD_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_FIELD_NULL
);
return
false
;
}
if
(
field
->
string
==
NULL
||
strlen
(
field
->
string
)
==
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_FIELD_NAME_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_FIELD_NAME_NULL
);
return
false
;
}
/*
...
...
@@ -545,17 +545,17 @@ bool tgProcessSingleMetric(HttpContext *pContext, cJSON *metric, char *db) {
*/
if
(
0
)
{
if
(
strlen
(
field
->
string
)
>=
TSDB_COL_NAME_LEN
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_FIELD_NAME_SIZE
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_FIELD_NAME_SIZE
);
return
false
;
}
}
if
(
field
->
type
!=
cJSON_Number
&&
field
->
type
!=
cJSON_String
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_FIELD_VALUE_TYPE
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_FIELD_VALUE_TYPE
);
return
false
;
}
if
(
field
->
type
==
cJSON_String
)
{
if
(
field
->
valuestring
==
NULL
||
strlen
(
field
->
valuestring
)
==
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_FIELD_VALUE_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_FIELD_VALUE_NULL
);
return
false
;
}
}
...
...
@@ -564,7 +564,7 @@ bool tgProcessSingleMetric(HttpContext *pContext, cJSON *metric, char *db) {
// assembling cmds
HttpSqlCmd
*
stable_cmd
=
httpNewSqlCmd
(
pContext
);
if
(
stable_cmd
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_NO_ENOUGH_MEMORY
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_NO_ENOUGH_MEMORY
);
return
false
;
}
stable_cmd
->
cmdType
=
HTTP_CMD_TYPE_CREATE_STBALE
;
...
...
@@ -572,7 +572,7 @@ bool tgProcessSingleMetric(HttpContext *pContext, cJSON *metric, char *db) {
HttpSqlCmd
*
table_cmd
=
httpNewSqlCmd
(
pContext
);
if
(
table_cmd
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_NO_ENOUGH_MEMORY
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_NO_ENOUGH_MEMORY
);
return
false
;
}
table_cmd
->
cmdType
=
HTTP_CMD_TYPE_INSERT
;
...
...
@@ -804,13 +804,13 @@ bool tgProcessQueryRequest(HttpContext *pContext, char *db) {
char
*
filter
=
pContext
->
parser
->
body
.
str
;
if
(
filter
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_NO_MSG_INPUT
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_NO_MSG_INPUT
);
return
false
;
}
cJSON
*
root
=
cJSON_Parse
(
filter
);
if
(
root
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_INVALID_JSON
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_INVALID_JSON
);
return
false
;
}
...
...
@@ -819,27 +819,27 @@ bool tgProcessQueryRequest(HttpContext *pContext, char *db) {
int32_t
size
=
cJSON_GetArraySize
(
metrics
);
httpDebug
(
"context:%p, fd:%d, multiple metrics:%d at one time"
,
pContext
,
pContext
->
fd
,
size
);
if
(
size
<=
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_METRICS_NULL
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_METRICS_NULL
);
cJSON_Delete
(
root
);
return
false
;
}
int32_t
cmdSize
=
size
*
2
+
1
;
if
(
cmdSize
>
HTTP_MAX_CMD_SIZE
)
{
httpSendErrorResp
(
pContext
,
HTTP_TG_METRICS_SIZE
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_TG_METRICS_SIZE
);
cJSON_Delete
(
root
);
return
false
;
}
if
(
!
httpMallocMultiCmds
(
pContext
,
cmdSize
,
HTTP_BUFFER_SIZE
))
{
httpSendErrorResp
(
pContext
,
HTTP_NO_ENOUGH_MEMORY
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_NO_ENOUGH_MEMORY
);
cJSON_Delete
(
root
);
return
false
;
}
HttpSqlCmd
*
cmd
=
httpNewSqlCmd
(
pContext
);
if
(
cmd
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_NO_ENOUGH_MEMORY
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_NO_ENOUGH_MEMORY
);
cJSON_Delete
(
root
);
return
false
;
}
...
...
@@ -860,14 +860,14 @@ bool tgProcessQueryRequest(HttpContext *pContext, char *db) {
httpDebug
(
"context:%p, fd:%d, single metric"
,
pContext
,
pContext
->
fd
);
if
(
!
httpMallocMultiCmds
(
pContext
,
3
,
HTTP_BUFFER_SIZE
))
{
httpSendErrorResp
(
pContext
,
HTTP_NO_ENOUGH_MEMORY
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_NO_ENOUGH_MEMORY
);
cJSON_Delete
(
root
);
return
false
;
}
HttpSqlCmd
*
cmd
=
httpNewSqlCmd
(
pContext
);
if
(
cmd
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_NO_ENOUGH_MEMORY
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_
HTTP_NO_ENOUGH_MEMORY
);
cJSON_Delete
(
root
);
return
false
;
}
...
...
@@ -892,7 +892,7 @@ bool tgProcessQueryRequest(HttpContext *pContext, char *db) {
bool
tgProcessRquest
(
struct
HttpContext
*
pContext
)
{
if
(
strlen
(
pContext
->
user
)
==
0
||
strlen
(
pContext
->
pass
)
==
0
)
{
httpSendErrorResp
(
pContext
,
HTTP_PARSE_USR_ERROR
);
httpSendErrorResp
(
pContext
,
TSDB_CODE_HTTP_NO_AUTH_INFO
);
return
false
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录