http_demo.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. /*================================================================
  2. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  3. Quectel Wireless Solution Proprietary and Confidential.
  4. =================================================================*/
  5. /*=================================================================
  6. EDIT HISTORY FOR MODULE
  7. This section contains comments describing changes made to the module.
  8. Notice that changes are listed in reverse chronological order.
  9. WHEN WHO WHAT, WHERE, WHY
  10. ------------ ------- -------------------------------------------------------------------------------
  11. =================================================================*/
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include <stdlib.h>
  15. #include "ql_api_osi.h"
  16. #include "ql_log.h"
  17. #include "ql_api_datacall.h"
  18. #include "ql_http_client.h"
  19. #include "ql_fs.h"
  20. #define QL_HTTP_LOG_LEVEL QL_LOG_LEVEL_INFO
  21. #define QL_HTTP_LOG(msg, ...) QL_LOG(QL_HTTP_LOG_LEVEL, "ql_HTTP", msg, ##__VA_ARGS__)
  22. #define QL_HTTP_LOG_PUSH(msg, ...) QL_LOG_PUSH("ql_HTTP", msg, ##__VA_ARGS__)
  23. typedef enum{
  24. QHTTPC_EVENT_RESPONSE = 1001,
  25. QHTTPC_EVENT_END,
  26. }qhttpc_event_code_e;
  27. typedef struct
  28. {
  29. http_client_t http_client;
  30. ql_queue_t queue;
  31. ql_mutex_t simple_lock;
  32. bool dl_block;
  33. int dl_high_line;
  34. int dl_total_len;
  35. QFILE upload_fd;
  36. QFILE dload_fd;
  37. }qhttpc_ctx_t;
  38. #define HTTP_MAX_MSG_CNT 8
  39. #define HTTP_DLOAD_HIGH_LINE 40960
  40. ql_task_t http_task = NULL;
  41. qhttpc_ctx_t http_demo_client = {0};
  42. static void http_event_cb(http_client_t *client, int evt, int evt_code, void *arg)
  43. {
  44. qhttpc_ctx_t *client_ptr = (qhttpc_ctx_t *)arg;
  45. ql_event_t qhttpc_event_send = {0};
  46. QL_HTTP_LOG("enter");
  47. if(client_ptr == NULL)
  48. return;
  49. QL_HTTP_LOG("*client:%d, http_cli:%d", *client, client_ptr->http_client);
  50. if(*client != client_ptr->http_client)
  51. return;
  52. QL_HTTP_LOG("evt:%d, evt_code:%d", evt, evt_code);
  53. switch(evt){
  54. case HTTP_EVENT_SESSION_ESTABLISH:{
  55. if(evt_code != QL_HTTP_OK){
  56. QL_HTTP_LOG("HTTP session create failed!!!!!");
  57. qhttpc_event_send.id = QHTTPC_EVENT_END;
  58. qhttpc_event_send.param1 = (uint32)client_ptr;
  59. ql_rtos_queue_release(client_ptr->queue, sizeof(ql_event_t), (uint8 *)&qhttpc_event_send, QL_WAIT_FOREVER);
  60. }
  61. }
  62. break;
  63. case HTTP_EVENT_RESPONE_STATE_LINE:{
  64. if(evt_code == QL_HTTP_OK){
  65. int resp_code = 0;
  66. int content_length = 0;
  67. int chunk_encode = 0;
  68. char *location = NULL;
  69. ql_httpc_getinfo(client, HTTP_INFO_RESPONSE_CODE, &resp_code);
  70. QL_HTTP_LOG("response code:%d", resp_code);
  71. ql_httpc_getinfo(client, HTTP_INFO_CHUNK_ENCODE, &chunk_encode);
  72. if(chunk_encode == 0){
  73. ql_httpc_getinfo(client, HTTP_INFO_CONTENT_LEN, &content_length);
  74. QL_HTTP_LOG("content_length:%d",content_length);
  75. }else{
  76. QL_HTTP_LOG("http chunk encode!!!");
  77. }
  78. if(resp_code >= 300 && resp_code < 400){
  79. ql_httpc_getinfo(client, HTTP_INFO_LOCATION, &location);
  80. QL_HTTP_LOG("redirect location:%s", location);
  81. free(location);
  82. }
  83. }
  84. }
  85. break;
  86. case HTTP_EVENT_SESSION_DISCONNECT:{
  87. if(evt_code == QL_HTTP_OK){
  88. QL_HTTP_LOG("===http transfer end!!!!");
  89. }else{
  90. QL_HTTP_LOG("===http transfer occur exception!!!!!");
  91. }
  92. qhttpc_event_send.id = QHTTPC_EVENT_END;
  93. qhttpc_event_send.param1 = (uint32)client_ptr;
  94. ql_rtos_queue_release(client_ptr->queue, sizeof(ql_event_t), (uint8 *)&qhttpc_event_send, QL_WAIT_FOREVER);
  95. }
  96. break;
  97. }
  98. }
  99. static int http_write_response_data(http_client_t *client, void *arg, char *data, int size, unsigned char end)
  100. {
  101. int ret = size;
  102. uint32 msg_cnt = 0;
  103. char *read_buff = NULL;
  104. qhttpc_ctx_t *client_ptr = (qhttpc_ctx_t *)arg;
  105. ql_event_t qhttpc_event_send = {0};
  106. QL_HTTP_LOG("enter");
  107. if(client_ptr == NULL)
  108. return 0;
  109. QL_HTTP_LOG("*client:%d, http_cli:%d", *client, client_ptr->http_client);
  110. if(*client != client_ptr->http_client)
  111. return 0;
  112. read_buff = (char *)malloc(size+1);
  113. if(read_buff == NULL)
  114. {
  115. QL_HTTP_LOG("mem faild");
  116. return 0;
  117. }
  118. memcpy(read_buff, data, size);
  119. if(QL_OSI_SUCCESS != ql_rtos_queue_get_cnt(client_ptr->queue, &msg_cnt))
  120. {
  121. free(read_buff);
  122. QL_HTTP_LOG("ql_rtos_queue_get_cnt faild");
  123. return 0;
  124. }
  125. ql_rtos_mutex_lock(client_ptr->simple_lock, 100);
  126. if(msg_cnt >= (HTTP_MAX_MSG_CNT-1) || (client_ptr->dl_total_len + size) >= client_ptr->dl_high_line)
  127. {
  128. client_ptr->dl_block = true;
  129. ret = QL_HTTP_ERROR_WONDBLOCK;
  130. }
  131. ql_rtos_mutex_unlock(client_ptr->simple_lock);
  132. QL_HTTP_LOG("msg_cnt %d, total_len+size %d", msg_cnt, (client_ptr->dl_total_len + size));
  133. qhttpc_event_send.id = QHTTPC_EVENT_RESPONSE;
  134. qhttpc_event_send.param1 = (uint32)client_ptr;
  135. qhttpc_event_send.param2 = (uint32)read_buff;
  136. qhttpc_event_send.param3 = (uint32)size;
  137. if(QL_OSI_SUCCESS != ql_rtos_queue_release(client_ptr->queue, sizeof(ql_event_t), (uint8 *)&qhttpc_event_send, 0))
  138. {
  139. free(read_buff);
  140. QL_HTTP_LOG("ql_rtos_queue_release faild");
  141. return 0;
  142. }
  143. ql_rtos_mutex_lock(client_ptr->simple_lock, 100);
  144. client_ptr->dl_total_len += size;
  145. ql_rtos_mutex_unlock(client_ptr->simple_lock);
  146. QL_HTTP_LOG("http response :%d bytes data", size);
  147. return ret;
  148. }
  149. static int http_read_request_data(http_client_t *client, void *arg, char *data, int size)
  150. {
  151. int ret = 0;
  152. QFILE fd = 0;
  153. qhttpc_ctx_t *client_ptr = (qhttpc_ctx_t *)arg;
  154. QL_HTTP_LOG("enter");
  155. if(client_ptr == NULL)
  156. return 0;
  157. QL_HTTP_LOG("*client:%d, http_cli:%d", *client, client_ptr->http_client);
  158. if(*client != client_ptr->http_client)
  159. return 0;
  160. ql_rtos_mutex_lock(client_ptr->simple_lock, 100);
  161. fd = client_ptr->upload_fd;
  162. ql_rtos_mutex_unlock(client_ptr->simple_lock);
  163. QL_HTTP_LOG("fd:%d", fd);
  164. if(fd < 0)
  165. return 0;
  166. QL_HTTP_LOG("read size:%d", size);
  167. ret = ql_fread(data, size, 1, fd);
  168. QL_HTTP_LOG("http read :%d bytes data", ret);
  169. if(ret > 0)
  170. return ret;
  171. return 0;
  172. }
  173. static void http_write_response_data_func(void *param)
  174. {
  175. int ret = 0;
  176. int size = 0;
  177. QFILE fd = 0;
  178. bool dload_block = false;
  179. char *read_buff = NULL;
  180. qhttpc_ctx_t *client_ptr = NULL;
  181. ql_event_t *qhttpc_event_recv = (ql_event_t *)param;
  182. if(qhttpc_event_recv == NULL || qhttpc_event_recv->param1 == 0 || qhttpc_event_recv->param2 == 0 || qhttpc_event_recv->param3 == 0)
  183. return;
  184. client_ptr = (qhttpc_ctx_t *)qhttpc_event_recv->param1;
  185. read_buff = (char *)qhttpc_event_recv->param2;
  186. size = (int)qhttpc_event_recv->param3;
  187. fd = (QFILE)client_ptr->dload_fd;
  188. ret = ql_fwrite(read_buff, size, 1, fd);
  189. free(read_buff);
  190. ql_rtos_mutex_lock(client_ptr->simple_lock, 100);
  191. client_ptr->dl_total_len -= size;
  192. if(client_ptr->dl_total_len < 0)
  193. client_ptr->dl_total_len = 0;
  194. if(client_ptr->dl_block == true && client_ptr->dl_total_len < client_ptr->dl_high_line)
  195. {
  196. dload_block = client_ptr->dl_block;
  197. client_ptr->dl_block = false;
  198. }
  199. ql_rtos_mutex_unlock(client_ptr->simple_lock);
  200. if(dload_block == true)
  201. ql_httpc_continue_dload(&client_ptr->http_client);
  202. QL_HTTP_LOG("http write :%d bytes data", ret);
  203. }
  204. static void http_app_thread(void * arg)
  205. {
  206. int ret = 0, i = 0;
  207. int profile_idx = 1;
  208. ql_data_call_info_s info;
  209. char ip4_addr_str[16] = {0};
  210. int run_num = 0;
  211. struct stat dload_stat;
  212. uint8_t nSim = 0;
  213. int flags_break = 0;
  214. ql_event_t qhttpc_event_msg = {0};
  215. ql_rtos_task_sleep_s(5);
  216. QL_HTTP_LOG("========== http demo start ==========");
  217. QL_HTTP_LOG("wait for network register done");
  218. while((ret = ql_network_register_wait(nSim, 120)) != 0 && i < 10){
  219. i++;
  220. ql_rtos_task_sleep_ms(1000);
  221. }
  222. if(ret == 0){
  223. i = 0;
  224. QL_HTTP_LOG("====network registered!!!!====");
  225. }else{
  226. QL_HTTP_LOG("====network register failure!!!!!====");
  227. goto exit;
  228. }
  229. ql_set_data_call_asyn_mode(nSim, profile_idx, 0);
  230. ret=ql_start_data_call(nSim, profile_idx, QL_PDP_TYPE_IP, "uninet", NULL, NULL, 0);
  231. if(ret != 0){
  232. QL_HTTP_LOG("====data call failure!!!!=====");
  233. }
  234. memset(&info, 0x00, sizeof(ql_data_call_info_s));
  235. ret = ql_get_data_call_info(nSim, profile_idx, &info);
  236. if(ret != 0){
  237. QL_HTTP_LOG("ql_get_data_call_info ret: %d", ret);
  238. ql_stop_data_call(nSim, profile_idx);
  239. goto exit;
  240. }
  241. QL_HTTP_LOG("info->profile_idx: %d", info.profile_idx);
  242. QL_HTTP_LOG("info->ip_version: %d", info.ip_version);
  243. QL_HTTP_LOG("info->v4.state: %d", info.v4.state);
  244. inet_ntop(AF_INET, &info.v4.addr.ip, ip4_addr_str, sizeof(ip4_addr_str));
  245. QL_HTTP_LOG("info.v4.addr.ip: %s\r\n", ip4_addr_str);
  246. inet_ntop(AF_INET, &info.v4.addr.pri_dns, ip4_addr_str, sizeof(ip4_addr_str));
  247. QL_HTTP_LOG("info.v4.addr.pri_dns: %s\r\n", ip4_addr_str);
  248. inet_ntop(AF_INET, &info.v4.addr.sec_dns, ip4_addr_str, sizeof(ip4_addr_str));
  249. QL_HTTP_LOG("info.v4.addr.sec_dns: %s\r\n", ip4_addr_str);
  250. while(run_num < 100){
  251. int http_method = HTTP_METHOD_NONE;
  252. int case_id = run_num%2;
  253. char dload_file[] = "UFS:http_dload.txt";
  254. char upload_file[] = "UFS:test_device.txt";
  255. QL_HTTP_LOG("==============http_client_test[%d]================\n",run_num+1);
  256. memset(&http_demo_client, 0x00, sizeof(qhttpc_ctx_t));
  257. http_demo_client.dl_block = false;
  258. http_demo_client.dl_high_line = HTTP_DLOAD_HIGH_LINE;
  259. ret = ql_rtos_mutex_create(&http_demo_client.simple_lock);
  260. if (ret)
  261. {
  262. QL_HTTP_LOG("ql_rtos_mutex_create failed!!!!");
  263. break;
  264. }
  265. ret = ql_rtos_queue_create(&http_demo_client.queue, sizeof(ql_event_t), HTTP_MAX_MSG_CNT);
  266. if (ret)
  267. {
  268. QL_HTTP_LOG("ql_rtos_queue_create failed!!!!");
  269. break;
  270. }
  271. if(ql_httpc_new(&http_demo_client.http_client, http_event_cb, (void *)&http_demo_client) != QL_HTTP_OK){
  272. QL_HTTP_LOG("http client create failed!!!!");
  273. break;
  274. }
  275. http_demo_client.dload_fd = ql_fopen(dload_file, "w+");
  276. if(http_demo_client.dload_fd < 0){
  277. QL_HTTP_LOG("open file failed!!!!");
  278. ql_httpc_release(&http_demo_client.http_client);
  279. goto exit;
  280. }
  281. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_SIM_ID, nSim);
  282. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_PDPCID, profile_idx);
  283. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_WRITE_FUNC, http_write_response_data);
  284. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_WRITE_DATA, (void *)&http_demo_client);
  285. switch(case_id){
  286. case 0:{//test http get
  287. char url[] = "http://220.180.239.212:8300/10K.txt";
  288. http_method = HTTP_METHOD_GET;
  289. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_METHOD, http_method);
  290. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_URL, (char *)url);
  291. }
  292. break;
  293. case 1:{//test https get
  294. char url[] = "https://220.180.239.212:8301/10K.txt";
  295. http_method = HTTP_METHOD_GET;
  296. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_METHOD, http_method);
  297. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_SSLCTXID, 1);
  298. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_SSL_VERIFY_LEVEL, HTTPS_VERIFY_NONE);
  299. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_URL, (char *)url);
  300. }
  301. break;
  302. case 2:{//test http post
  303. char url[] = "http://220.180.239.212:8252/http_post/";
  304. struct stat stat_buf;
  305. http_method = HTTP_METHOD_POST;
  306. http_demo_client.upload_fd = ql_fopen(upload_file, "r");
  307. if(http_demo_client.upload_fd < 0){
  308. ql_fclose(http_demo_client.dload_fd);
  309. ql_httpc_release(&http_demo_client.http_client);
  310. goto exit;
  311. }
  312. memset(&stat_buf, 0x00, sizeof(struct stat));
  313. ql_fstat(http_demo_client.upload_fd, &stat_buf);
  314. QL_HTTP_LOG("file size:%d", stat_buf.st_size);
  315. if(stat_buf.st_size == 0){
  316. ql_fclose(http_demo_client.upload_fd);
  317. ql_fclose(http_demo_client.dload_fd);
  318. ql_httpc_release(&http_demo_client.http_client);
  319. }
  320. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_METHOD, http_method);
  321. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_URL, (char *)url);
  322. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_REQUEST_HEADER, "Content-type: multipart/form-data");
  323. ql_httpc_formadd(&http_demo_client.http_client, HTTP_FORM_NAME, "file");
  324. ql_httpc_formadd(&http_demo_client.http_client, HTTP_FORM_FILENAME, "http_test.txt");
  325. ql_httpc_formadd(&http_demo_client.http_client, HTTP_FORM_CONTENT_TYPE, "text/plain");
  326. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_READ_FUNC, http_read_request_data);
  327. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_READ_DATA, (void *)&http_demo_client);
  328. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_UPLOAD_LEN, stat_buf.st_size);
  329. }
  330. break;
  331. case 3:{//test http put
  332. char url[256] = {0};
  333. struct stat stat_buf;
  334. http_method = HTTP_METHOD_PUT;
  335. http_demo_client.upload_fd = ql_fopen(upload_file, "r");
  336. if(http_demo_client.upload_fd < 0){
  337. ql_fclose(http_demo_client.dload_fd);
  338. ql_httpc_release(&http_demo_client.http_client);
  339. goto exit;
  340. }
  341. memset(&stat_buf, 0x00, sizeof(struct stat));
  342. ql_fstat(http_demo_client.upload_fd, &stat_buf);
  343. if(stat_buf.st_size == 0){
  344. ql_fclose(http_demo_client.upload_fd);
  345. ql_fclose(http_demo_client.dload_fd);
  346. ql_httpc_release(&http_demo_client.http_client);
  347. }
  348. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_METHOD, http_method);
  349. snprintf(url, 256,"%s%d.txt","http://220.180.239.212:8252/uploads/test", run_num/2);
  350. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_URL, (char *)url);
  351. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_READ_FUNC, http_read_request_data);
  352. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_READ_DATA, (void *)&http_demo_client);
  353. ql_httpc_setopt(&http_demo_client.http_client, HTTP_CLIENT_OPT_UPLOAD_LEN, stat_buf.st_size);
  354. }
  355. break;
  356. }
  357. if(ql_httpc_perform(&http_demo_client.http_client) == QL_HTTP_OK)
  358. {
  359. QL_HTTP_LOG("wait http perform end!!!!!!");
  360. flags_break = 0;
  361. for (;;)
  362. {
  363. memset(&qhttpc_event_msg, 0x00, sizeof(ql_event_t));
  364. ql_rtos_queue_wait(http_demo_client.queue, (uint8 *)&qhttpc_event_msg, sizeof(ql_event_t), QL_WAIT_FOREVER);
  365. switch(qhttpc_event_msg.id)
  366. {
  367. case QHTTPC_EVENT_RESPONSE:
  368. {
  369. http_write_response_data_func((void *)&qhttpc_event_msg);
  370. }
  371. break;
  372. case QHTTPC_EVENT_END:
  373. {
  374. flags_break = 1;
  375. }
  376. break;
  377. default:
  378. break;
  379. }
  380. if(flags_break)
  381. break;
  382. }
  383. }else{
  384. QL_HTTP_LOG("http perform failed!!!!!!!!!!");
  385. }
  386. memset(&dload_stat, 0x00, sizeof(struct stat));
  387. ql_fstat(http_demo_client.dload_fd, &dload_stat);
  388. QL_HTTP_LOG("=========dload_file_size:%d", dload_stat.st_size);
  389. if(http_demo_client.dload_fd >= 0){
  390. ql_fclose(http_demo_client.dload_fd);
  391. http_demo_client.dload_fd = -1;
  392. }
  393. ql_rtos_mutex_lock(http_demo_client.simple_lock, 100);
  394. if(http_demo_client.upload_fd >= 0){
  395. ql_fclose(http_demo_client.upload_fd);
  396. http_demo_client.upload_fd = -1;
  397. }
  398. ql_rtos_mutex_unlock(http_demo_client.simple_lock);
  399. ql_httpc_release(&http_demo_client.http_client);
  400. http_demo_client.http_client = 0;
  401. QL_HTTP_LOG("==============http_client_test_end[%d]================\n",run_num+1);
  402. run_num++;
  403. if(http_demo_client.queue != NULL)
  404. {
  405. while(1)
  406. {
  407. memset(&qhttpc_event_msg, 0x00, sizeof(ql_event_t));
  408. if(QL_OSI_SUCCESS != ql_rtos_queue_wait(http_demo_client.queue, (uint8 *)&qhttpc_event_msg, sizeof(ql_event_t), 0))
  409. break;
  410. switch(qhttpc_event_msg.id)
  411. {
  412. case QHTTPC_EVENT_RESPONSE:
  413. {
  414. free((void *)(qhttpc_event_msg.param2));
  415. }
  416. break;
  417. default:
  418. break;
  419. }
  420. }
  421. ql_rtos_queue_delete(http_demo_client.queue);
  422. http_demo_client.queue = NULL;
  423. }
  424. ql_rtos_mutex_delete(http_demo_client.simple_lock);
  425. http_demo_client.simple_lock = NULL;
  426. ql_rtos_task_sleep_s(3);
  427. }
  428. exit:
  429. if(http_demo_client.queue != NULL)
  430. {
  431. while(1)
  432. {
  433. memset(&qhttpc_event_msg, 0x00, sizeof(ql_event_t));
  434. if(QL_OSI_SUCCESS != ql_rtos_queue_wait(http_demo_client.queue, (uint8 *)&qhttpc_event_msg, sizeof(ql_event_t), 0))
  435. break;
  436. switch(qhttpc_event_msg.id)
  437. {
  438. case QHTTPC_EVENT_RESPONSE:
  439. {
  440. free((void *)(qhttpc_event_msg.param2));
  441. }
  442. break;
  443. default:
  444. break;
  445. }
  446. }
  447. ql_rtos_queue_delete(http_demo_client.queue);
  448. }
  449. if(http_demo_client.simple_lock != NULL)
  450. ql_rtos_mutex_delete(http_demo_client.simple_lock);
  451. ql_rtos_task_delete(http_task);
  452. return;
  453. }
  454. void ql_http_app_init(void)
  455. {
  456. QlOSStatus err = QL_OSI_SUCCESS;
  457. err = ql_rtos_task_create(&http_task, 4096, APP_PRIORITY_NORMAL, "QhttpApp", http_app_thread, NULL, 5);
  458. if(err != QL_OSI_SUCCESS)
  459. {
  460. QL_HTTP_LOG("created task failed");
  461. }
  462. }