Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3eaaf27d
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3eaaf27d
编写于
3月 02, 2021
作者:
S
Shuduo Sang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-3113] <fix>: remove curl from TDengine. cleanup.
上级
d88c2970
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
150 deletion
+0
-150
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+0
-150
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
3eaaf27d
...
...
@@ -1508,156 +1508,6 @@ static void printfQuerySystemInfo(TAOS * taos) {
}
#ifdef TD_LOWA_CURL
#if 0
static size_t responseCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
size_t realsize = size * nmemb;
curlMemInfo* mem = (curlMemInfo*)userp;
char *ptr = realloc(mem->buf, mem->sizeleft + realsize + 1);
if(ptr == NULL) {
/* out of memory! */
printf("not enough memory (realloc returned NULL)\n");
return 0;
}
mem->buf = ptr;
memcpy(&(mem->buf[mem->sizeleft]), contents, realsize);
mem->sizeleft += realsize;
mem->buf[mem->sizeleft] = 0;
//printf("result:%s\n\n", mem->buf);
return realsize;
}
void curlProceLogin(void)
{
CURL *curl_handle;
CURLcode res;
curlMemInfo chunk;
chunk.buf = malloc(1); /* will be grown as needed by the realloc above */
chunk.sizeleft = 0; /* no data at this point */
//curl_global_init(CURL_GLOBAL_ALL);
/* init the curl session */
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle,CURLOPT_POSTFIELDS,"");
curl_easy_setopt(curl_handle, CURLOPT_POST, 1);
char dstUrl[128] = {0};
snprintf(dstUrl, 128, "http://%s:6041/rest/login/root/taosdata", g_Dbs.host);
/* specify URL to get */
curl_easy_setopt(curl_handle, CURLOPT_URL, dstUrl);
/* send all data to this function */
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, responseCallback);
/* we pass our 'chunk' struct to the callback function */
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
/* do it! */
res = curl_easy_perform(curl_handle);
/* check for errors */
if(res != CURLE_OK) {
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
}
else {
//printf("response len:%lu, content: %s \n", (unsigned long)chunk.sizeleft, chunk.buf);
;
}
/* cleanup curl stuff */
curl_easy_cleanup(curl_handle);
free(chunk.buf);
/* we're done with libcurl, so clean it up */
//curl_global_cleanup();
return;
}
#endif
int
curlProceSql
(
char
*
host
,
uint16_t
port
,
char
*
sqlstr
,
CURL
*
curl_handle
)
{
//curlProceLogin();
//CURL *curl_handle;
CURLcode
res
;
curlMemInfo
chunk
;
chunk
.
buf
=
malloc
(
1
);
/* will be grown as needed by the realloc above */
chunk
.
sizeleft
=
0
;
/* no data at this point */
char
dstUrl
[
128
]
=
{
0
};
snprintf
(
dstUrl
,
128
,
"http://%s:%u/rest/sql"
,
host
,
port
+
TSDB_PORT_HTTP
);
//curl_global_init(CURL_GLOBAL_ALL);
/* init the curl session */
//curl_handle = curl_easy_init();
//curl_easy_setopt(curl_handle,CURLOPT_POSTFIELDS,"");
curl_easy_setopt
(
curl_handle
,
CURLOPT_POST
,
1L
);
/* specify URL to get */
curl_easy_setopt
(
curl_handle
,
CURLOPT_URL
,
dstUrl
);
/* enable TCP keep-alive for this transfer */
curl_easy_setopt
(
curl_handle
,
CURLOPT_TCP_KEEPALIVE
,
1L
);
/* keep-alive idle time to 120 seconds */
curl_easy_setopt
(
curl_handle
,
CURLOPT_TCP_KEEPIDLE
,
120L
);
/* interval time between keep-alive probes: 60 seconds */
curl_easy_setopt
(
curl_handle
,
CURLOPT_TCP_KEEPINTVL
,
60L
);
/* send all data to this function */
curl_easy_setopt
(
curl_handle
,
CURLOPT_WRITEFUNCTION
,
responseCallback
);
/* we pass our 'chunk' struct to the callback function */
curl_easy_setopt
(
curl_handle
,
CURLOPT_WRITEDATA
,
(
void
*
)
&
chunk
);
struct
curl_slist
*
list
=
NULL
;
list
=
curl_slist_append
(
list
,
"Authorization: Basic cm9vdDp0YW9zZGF0YQ=="
);
curl_easy_setopt
(
curl_handle
,
CURLOPT_HTTPHEADER
,
list
);
curl_easy_setopt
(
curl_handle
,
CURLOPT_HTTPHEADER
,
list
);
/* Set the expected upload size. */
curl_easy_setopt
(
curl_handle
,
CURLOPT_POSTFIELDSIZE_LARGE
,
(
curl_off_t
)
strlen
(
sqlstr
));
curl_easy_setopt
(
curl_handle
,
CURLOPT_POSTFIELDS
,
sqlstr
);
/* get it! */
res
=
curl_easy_perform
(
curl_handle
);
/* check for errors */
if
(
res
!=
CURLE_OK
)
{
fprintf
(
stderr
,
"curl_easy_perform() failed: %s
\n
"
,
curl_easy_strerror
(
res
));
return
-
1
;
}
else
{
/* curl_easy_perform() block end and return result */
//printf("[%32.32s] sql response len:%lu, content: %s \n\n", sqlstr, (unsigned long)chunk.sizeleft, chunk.buf);
;
}
curl_slist_free_all
(
list
);
/* free the list again */
free
(
chunk
.
buf
);
return
0
;
}
#endif
#define REQ_EXTRA_BUF_LEN 1024
#define RESP_BUF_LEN 4096
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录