2019-07-28 10:31:56 +08:00
|
|
|
|
#ifndef __LIB_HTTP_UTIL_INCLUDE_H__
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#define __LIB_HTTP_UTIL_INCLUDE_H__
|
|
|
|
|
|
|
|
|
|
#include "lib_http_struct.h"
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
typedef struct HTTP_UTIL {
|
2019-07-28 10:31:56 +08:00
|
|
|
|
HTTP_HDR_REQ *hdr_req; /**< HTTP <20><><EFBFBD><EFBFBD>ͷ */
|
|
|
|
|
HTTP_HDR_RES *hdr_res; /**< HTTP <20><>Ӧͷ */
|
|
|
|
|
HTTP_RES *http_res; /**< HTTP <20><>Ӧ<EFBFBD><D3A6> */
|
|
|
|
|
char server_addr[256]; /**< Զ<><D4B6> HTTP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ */
|
|
|
|
|
ACL_VSTREAM *stream; /**< <20><> HTTP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int conn_timeout; /**< <20><><EFBFBD><EFBFBD> HTTP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>ʱʱ<CAB1><CAB1> */
|
|
|
|
|
int rw_timeout; /**< <20><> HTTP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>ʱÿ<CAB1><C3BF> IO <20>ij<EFBFBD>ʱʱ<CAB1><CAB1> */
|
|
|
|
|
ACL_VSTRING *req_buf; /**< <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int res_body_dlen; /**< HTTP <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD> */
|
|
|
|
|
ACL_VSTREAM *dump_stream; /**< ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD> */
|
|
|
|
|
unsigned int flag; /**< <20><>־λ */
|
|
|
|
|
#define HTTP_UTIL_FLAG_SET_DUMP_FILE (1 << 0) /**< <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD> */
|
|
|
|
|
#define HTTP_UTIL_FLAG_SET_DUMP_STREAM (1 << 1) /**< <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
#define HTTP_UTIL_FLAG_HAS_RES_BODY (1 << 2) /**< <20><> HTTP <20><>Ӧ<EFBFBD><D3A6> */
|
|
|
|
|
#define HTTP_UTIL_FLAG_NO_RES_BODY (1 << 3) /**< <20><> HTTP <20><>Ӧ<EFBFBD><D3A6> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
} HTTP_UTIL;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> HTTP_UTIL <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param url {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> url
|
|
|
|
|
* @param method {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>GET, POST, HEAD, CONNECT
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {HTTP_UTIL*}
|
|
|
|
|
*/
|
|
|
|
|
HTTP_API HTTP_UTIL *http_util_req_new(const char *url, const char *method);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> HTTP_UTIL <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param status {int} ״̬<EFBFBD>룬<EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD>Ϊ: 1xx, 2xx, 3xx, 4xx, 5xx
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {HTTP_UTIL*}
|
|
|
|
|
*/
|
|
|
|
|
HTTP_API HTTP_UTIL *http_util_res_new(int status);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ͷ<EFBFBD>һ<EFBFBD><EFBFBD> HTTP_UTIL <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
|
|
|
|
*/
|
|
|
|
|
HTTP_API void http_util_free(HTTP_UTIL *http_util);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>Ϣ, <EFBFBD><EFBFBD>: Accept-Encoding: gzip,deflate
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param name {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD> Accept-Encoding
|
|
|
|
|
* @param value {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>ֶε<EFBFBD>ֵ, <EFBFBD><EFBFBD> gzip,deflate
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API void http_util_set_req_entry(HTTP_UTIL *http_util, const char *name, const char *value);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ر<EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>е<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶΣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶβ<EFBFBD><EFBFBD>ᷢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param name {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD> Accept-Encoding
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API void http_util_off_req_entry(HTTP_UTIL *http_util, const char *name);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>ֶε<EFBFBD>ֵ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param name {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD> Accept-Encoding
|
|
|
|
|
* @return {char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶβ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API char *http_util_get_req_value(HTTP_UTIL *http_util, const char *name);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>ֶε<EFBFBD> HTTP_HDR_ENTRY <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param name {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD> Accept-Encoding
|
|
|
|
|
* @return {HTTP_HDR_ENTRY*} <EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ֶβ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API HTTP_HDR_ENTRY *http_util_get_req_entry(HTTP_UTIL *http_util, const char *name);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param len {int} HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>峤<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD><EFBFBD><EFBFBD> >= 0)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API void http_util_set_req_content_length(HTTP_UTIL *http_util, int len);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD> HTTP <EFBFBD>Ự<EFBFBD><EFBFBD><EFBFBD>ֳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵĴ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>λΪ<EFBFBD><EFBFBD>)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param timeout {int} HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵĴ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>λΪ<EFBFBD><EFBFBD>)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API void http_util_set_req_keep_alive(HTTP_UTIL *http_util, int timeout);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD> Connection <EFBFBD>ֶ<EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param value {const char*} <EFBFBD>ֶ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>Ϊ: keep-alive, close
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API void http_util_set_req_connection(HTTP_UTIL *http_util, const char *value);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>е<EFBFBD> Referer <EFBFBD>ֶ<EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param refer {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> url, <EFBFBD><EFBFBD>: http://www.test.com
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API void http_util_set_req_refer(HTTP_UTIL *http_util, const char *refer);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>е<EFBFBD> Cookie <EFBFBD>ֶΣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD>ʽ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param name {const char*} Cookie <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param value {const char*} Cookie ֵ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API void http_util_set_req_cookie(HTTP_UTIL *http_util, const char *name, const char *value);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param proxy {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>ʽΪ: IP:PORT, DOMAIN:PORT,
|
|
|
|
|
* <EFBFBD><EFBFBD>: 192.168.0.1:80, 192.168.0.2:8088, www.g.cn:80
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API void http_util_set_req_proxy(HTTP_UTIL *http_util, const char *proxy);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><EFBFBD><EFBFBD>ͬʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param stream {ACL_VSTREAM *} ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API void http_util_set_dump_stream(HTTP_UTIL *http_util, ACL_VSTREAM *stream);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><EFBFBD>ļ<EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param filename {const char*} ת<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ < 0 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API int http_util_set_dump_file(HTTP_UTIL *http_util, const char *filename);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>ͬʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><EFBFBD>ҽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {int} 0: <EFBFBD>ɹ<EFBFBD>; -1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API int http_util_req_open(HTTP_UTIL *http_util);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> POST <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|
|
|
|
* <EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD>ε<EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param data {const char*} <EFBFBD><EFBFBD><EFBFBD>η<EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD>
|
|
|
|
|
* @param dlen {size_t} data <EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0
|
2019-09-20 21:54:02 +08:00
|
|
|
|
* @return {int} > 0 <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>γɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>; -1: <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>, Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* http_util_free <EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>Դ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API int http_util_put_req_data(HTTP_UTIL *http_util, const char *data, size_t dlen);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧͷ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {int} 0: <EFBFBD>ɹ<EFBFBD>; -1: ʧ<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API int http_util_get_res_hdr(HTTP_UTIL *http_util);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧͷ<EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ֵ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param name {const char*} <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD> Content-Length
|
|
|
|
|
* @return {char*} <EFBFBD><EFBFBD>Ӧ name <EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ֵ, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ֶβ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API char *http_util_get_res_value(HTTP_UTIL *http_util, const char *name);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧͷ<EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>ֶζ<EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param name {const char*} <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD> Content-Length
|
|
|
|
|
* @return {HTTP_HDR_ENTRY*} <EFBFBD><EFBFBD>Ӧ name <EFBFBD><EFBFBD><EFBFBD>ֶζ<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ֶβ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API HTTP_HDR_ENTRY *http_util_get_res_entry(HTTP_UTIL *http_util, const char *name);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧͷ<EFBFBD>е<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ֵ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param name {const char*} <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD> Content-Type
|
|
|
|
|
* @param value {const char*} <EFBFBD>ֶ<EFBFBD>ֵ, <EFBFBD><EFBFBD> text/html
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API void http_util_set_res_entry(HTTP_UTIL *http_util, const char *name, const char *value);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ر<EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧͷ<EFBFBD>е<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param name {const char*} <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD> Content-Type
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API void http_util_off_res_entry(HTTP_UTIL *http_util, const char *name);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {int} 0: <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>; !0: <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API int http_util_has_res_body(HTTP_UTIL *http_util);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ <= 0, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬʱ<EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param http_util {HTTP_UTIL*}
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param buf {char *} <EFBFBD>洢 HTTP <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param size {size_t} buf <EFBFBD>Ŀռ<EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
* @return {int} <= 0: <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>; > 0: <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API int http_util_get_res_body(HTTP_UTIL *http_util, char *buf, size_t size);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD> url <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param url {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> url, <EFBFBD><EFBFBD>: http://www.g.cn
|
|
|
|
|
* @param dump {const char*} ת<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
2019-09-20 21:54:02 +08:00
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>, >=0: <EFBFBD><EFBFBD>ʾ<EFBFBD>ɹ<EFBFBD>, -1: <EFBFBD><EFBFBD>ʾʧ<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API int http_util_dump_url(const char *url, const char *dump);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD> url <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param url {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> url, <EFBFBD><EFBFBD>: http://www.g.cn
|
|
|
|
|
* @param stream {ACL_VSTREAM *} ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2019-09-20 21:54:02 +08:00
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>, >=0: <EFBFBD><EFBFBD>ʾ<EFBFBD>ɹ<EFBFBD>, -1: <EFBFBD><EFBFBD>ʾʧ<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
HTTP_API int http_util_dump_url_to_stream(const char *url, ACL_VSTREAM *stream);
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|