[TD-19] refactor http module
This commit is contained in:
parent
af305abdc8
commit
0eb45e7a2e
|
@ -13,11 +13,13 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gcHandle.h"
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
#include "cJSON.h"
|
#include "cJSON.h"
|
||||||
|
#include "httpLog.h"
|
||||||
|
#include "gcHandle.h"
|
||||||
#include "gcJson.h"
|
#include "gcJson.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "httpLog.h"
|
|
||||||
|
|
||||||
static HttpDecodeMethod gcDecodeMethod = {"grafana", gcProcessRequest};
|
static HttpDecodeMethod gcDecodeMethod = {"grafana", gcProcessRequest};
|
||||||
static HttpEncodeMethod gcHeartBeatMethod = {NULL, gcSendHeartBeatResp, NULL, NULL, NULL, NULL, NULL, NULL};
|
static HttpEncodeMethod gcHeartBeatMethod = {NULL, gcSendHeartBeatResp, NULL, NULL, NULL, NULL, NULL, NULL};
|
||||||
|
|
|
@ -13,10 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#define _DEFAULT_SOURCE
|
||||||
#include <string.h>
|
#include "os.h"
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "gcHandle.h"
|
#include "gcHandle.h"
|
||||||
#include "gcJson.h"
|
#include "gcJson.h"
|
||||||
#include "httpJson.h"
|
#include "httpJson.h"
|
||||||
|
|
|
@ -13,12 +13,14 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "tkey.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
#include "httpLog.h"
|
#include "httpLog.h"
|
||||||
#include "httpHandle.h"
|
#include "httpHandle.h"
|
||||||
#include "tkey.h"
|
|
||||||
#define KEY_DES_4 4971256377704625728L
|
#define KEY_DES_4 4971256377704625728L
|
||||||
|
|
||||||
bool httpParseBasicAuthToken(HttpContext *pContext, char *token, int len) {
|
bool httpParseBasicAuthToken(HttpContext *pContext, char *token, int len) {
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
|
||||||
|
|
||||||
char* httpMsg[] = {
|
char* httpMsg[] = {
|
||||||
"success", // 0
|
"success", // 0
|
||||||
"http server is not online", // 1
|
"http server is not online", // 1
|
||||||
|
|
|
@ -13,21 +13,18 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#define _DEFAULT_SOURCE
|
||||||
#include <stdint.h>
|
#include "os.h"
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "http.h"
|
|
||||||
#include "httpCode.h"
|
|
||||||
#include "httpHandle.h"
|
|
||||||
#include "httpResp.h"
|
|
||||||
#include "shash.h"
|
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tsocket.h"
|
#include "tsocket.h"
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
|
#include "shash.h"
|
||||||
|
#include "http.h"
|
||||||
#include "httpLog.h"
|
#include "httpLog.h"
|
||||||
|
#include "httpCode.h"
|
||||||
|
#include "httpHandle.h"
|
||||||
|
#include "httpResp.h"
|
||||||
|
|
||||||
void httpToLowerUrl(char* url) {
|
void httpToLowerUrl(char* url) {
|
||||||
/*ignore case */
|
/*ignore case */
|
||||||
|
|
|
@ -13,20 +13,15 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#define _DEFAULT_SOURCE
|
||||||
#include <stdio.h>
|
#include "os.h"
|
||||||
#include <stdlib.h>
|
#include "taosmsg.h"
|
||||||
#include <string.h>
|
#include "taoserror.h"
|
||||||
#include <unistd.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
#include "httpLog.h"
|
||||||
#include "httpCode.h"
|
#include "httpCode.h"
|
||||||
#include "httpJson.h"
|
#include "httpJson.h"
|
||||||
#include "httpResp.h"
|
#include "httpResp.h"
|
||||||
#include "taosmsg.h"
|
|
||||||
#include "httpLog.h"
|
|
||||||
#include "taoserror.h"
|
|
||||||
|
|
||||||
#define MAX_NUM_STR_SZ 25
|
#define MAX_NUM_STR_SZ 25
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,14 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "httpResp.h"
|
#define _DEFAULT_SOURCE
|
||||||
#include <stdio.h>
|
#include "os.h"
|
||||||
#include <string.h>
|
#include "taoserror.h"
|
||||||
#include "httpCode.h"
|
|
||||||
#include "httpJson.h"
|
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "httpLog.h"
|
#include "httpLog.h"
|
||||||
#include "taoserror.h"
|
#include "httpResp.h"
|
||||||
|
#include "httpCode.h"
|
||||||
|
#include "httpJson.h"
|
||||||
|
|
||||||
const char *httpKeepAliveStr[] = {"", "Connection: Keep-Alive\r\n", "Connection: Close\r\n"};
|
const char *httpKeepAliveStr[] = {"", "Connection: Keep-Alive\r\n", "Connection: Close\r\n"};
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tsocket.h"
|
#include "tsocket.h"
|
||||||
|
|
|
@ -13,20 +13,18 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#define _DEFAULT_SOURCE
|
||||||
#include <time.h>
|
#include "os.h"
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "http.h"
|
|
||||||
#include "httpCode.h"
|
|
||||||
#include "httpHandle.h"
|
|
||||||
#include "httpResp.h"
|
|
||||||
|
|
||||||
#include "shash.h"
|
#include "shash.h"
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
|
#include "http.h"
|
||||||
#include "httpLog.h"
|
#include "httpLog.h"
|
||||||
|
#include "httpCode.h"
|
||||||
|
#include "httpHandle.h"
|
||||||
|
#include "httpResp.h"
|
||||||
|
|
||||||
|
|
||||||
void httpAccessSession(HttpContext *pContext) {
|
void httpAccessSession(HttpContext *pContext) {
|
||||||
HttpServer *server = pContext->pThread->pServer;
|
HttpServer *server = pContext->pThread->pServer;
|
||||||
|
|
|
@ -13,15 +13,16 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "tnote.h"
|
||||||
|
#include "taos.h"
|
||||||
|
#include "tsclient.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
#include "httpLog.h"
|
||||||
#include "httpCode.h"
|
#include "httpCode.h"
|
||||||
#include "httpHandle.h"
|
#include "httpHandle.h"
|
||||||
#include "httpResp.h"
|
#include "httpResp.h"
|
||||||
#include "taos.h"
|
|
||||||
#include "tsclient.h"
|
|
||||||
#include "tnote.h"
|
|
||||||
#include "httpLog.h"
|
|
||||||
|
|
||||||
void *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int),
|
void *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int),
|
||||||
void *param, void **taos);
|
void *param, void **taos);
|
||||||
|
|
|
@ -15,17 +15,17 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "shash.h"
|
||||||
|
#include "taos.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "tsocket.h"
|
||||||
|
#include "ttimer.h"
|
||||||
#include "tadmin.h"
|
#include "tadmin.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
#include "httpCode.h"
|
#include "httpCode.h"
|
||||||
#include "httpHandle.h"
|
#include "httpHandle.h"
|
||||||
#include "httpResp.h"
|
#include "httpResp.h"
|
||||||
#include "httpLog.h"
|
#include "httpLog.h"
|
||||||
#include "shash.h"
|
|
||||||
#include "taos.h"
|
|
||||||
#include "tglobal.h"
|
|
||||||
#include "tsocket.h"
|
|
||||||
#include "ttimer.h"
|
|
||||||
#include "gcHandle.h"
|
#include "gcHandle.h"
|
||||||
#include "httpHandle.h"
|
#include "httpHandle.h"
|
||||||
#include "restHandle.h"
|
#include "restHandle.h"
|
||||||
|
|
|
@ -13,15 +13,16 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tmd5.h"
|
#include "tmd5.h"
|
||||||
|
#include "shash.h"
|
||||||
|
#include "taos.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
#include "httpLog.h"
|
||||||
#include "httpCode.h"
|
#include "httpCode.h"
|
||||||
#include "httpHandle.h"
|
#include "httpHandle.h"
|
||||||
#include "httpResp.h"
|
#include "httpResp.h"
|
||||||
#include "shash.h"
|
|
||||||
#include "taos.h"
|
|
||||||
#include "httpLog.h"
|
|
||||||
|
|
||||||
bool httpCheckUsedbSql(char *sql) {
|
bool httpCheckUsedbSql(char *sql) {
|
||||||
if (strstr(sql, "use ") != NULL) {
|
if (strstr(sql, "use ") != NULL) {
|
||||||
|
|
|
@ -13,9 +13,11 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
|
#include "httpLog.h"
|
||||||
#include "restHandle.h"
|
#include "restHandle.h"
|
||||||
#include "restJson.h"
|
#include "restJson.h"
|
||||||
#include "httpLog.h"
|
|
||||||
|
|
||||||
static HttpDecodeMethod restDecodeMethod = {"rest", restProcessRequest};
|
static HttpDecodeMethod restDecodeMethod = {"rest", restProcessRequest};
|
||||||
static HttpDecodeMethod restDecodeMethod2 = {"restful", restProcessRequest};
|
static HttpDecodeMethod restDecodeMethod2 = {"restful", restProcessRequest};
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "httpLog.h"
|
#include "httpLog.h"
|
||||||
|
|
|
@ -13,14 +13,15 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tgHandle.h"
|
|
||||||
#include "shash.h"
|
|
||||||
#include "taosmsg.h"
|
|
||||||
#include "tgJson.h"
|
|
||||||
#include "taosdef.h"
|
|
||||||
#include "httpLog.h"
|
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
#include "shash.h"
|
||||||
|
#include "taosdef.h"
|
||||||
|
#include "taosmsg.h"
|
||||||
|
#include "tgHandle.h"
|
||||||
|
#include "tgJson.h"
|
||||||
|
#include "httpLog.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* taos.telegraf.cfg formats like
|
* taos.telegraf.cfg formats like
|
||||||
|
|
|
@ -13,13 +13,14 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "taosmsg.h"
|
||||||
|
#include "httpLog.h"
|
||||||
#include "httpJson.h"
|
#include "httpJson.h"
|
||||||
#include "httpResp.h"
|
#include "httpResp.h"
|
||||||
#include "taosmsg.h"
|
|
||||||
#include "tgHandle.h"
|
#include "tgHandle.h"
|
||||||
#include "tgJson.h"
|
#include "tgJson.h"
|
||||||
#include "httpLog.h"
|
|
||||||
|
|
||||||
void tgInitQueryJson(HttpContext *pContext) {
|
void tgInitQueryJson(HttpContext *pContext) {
|
||||||
JsonBuf *jsonBuf = httpMallocJsonBuf(pContext);
|
JsonBuf *jsonBuf = httpMallocJsonBuf(pContext);
|
||||||
|
|
Loading…
Reference in New Issue