| 208 | } |
| 209 | |
| 210 | int http_util_req_open(HTTP_UTIL *http_util) |
| 211 | { |
| 212 | const char *myname = "http_util_req_open"; |
| 213 | int ret; |
| 214 | |
| 215 | /* ����Զ�� http ������ */ |
| 216 | |
| 217 | http_util->stream = acl_vstream_connect(http_util->server_addr, |
| 218 | ACL_BLOCKING /* ����������ʽ */, |
| 219 | http_util->conn_timeout /* ���ӳ�ʱʱ�� */, |
| 220 | http_util->rw_timeout /* ���� IO ������ʱʱ�� */, |
| 221 | 4096 /* stream ����������СΪ 4096 �ֽ� */); |
| 222 | if (http_util->stream == NULL) { |
| 223 | acl_msg_error("%s(%d): connect %s error(%s)", |
| 224 | myname, __LINE__, http_util->server_addr, |
| 225 | acl_last_serror()); |
| 226 | return (-1); |
| 227 | } |
| 228 | |
| 229 | /* ���� HTTP ����ͷ���� */ |
| 230 | |
| 231 | http_hdr_build_request(http_util->hdr_req, http_util->req_buf); |
| 232 | |
| 233 | /* �� HTTP �������������� */ |
| 234 | |
| 235 | ret = acl_vstream_writen(http_util->stream, |
| 236 | acl_vstring_str(http_util->req_buf), |
| 237 | ACL_VSTRING_LEN(http_util->req_buf)); |
| 238 | if (ret == ACL_VSTREAM_EOF) { |
| 239 | acl_msg_error("%s(%d): send request to server(%s) error(%s)", |
| 240 | myname, __LINE__, http_util->server_addr, |
| 241 | acl_last_serror()); |
| 242 | return (-1); |
| 243 | } |
| 244 | |
| 245 | return (0); |
| 246 | } |
| 247 | |
| 248 | int http_util_put_req_data(HTTP_UTIL *http_util, const char *data, size_t dlen) |
| 249 | { |
no test coverage detected
searching dependent graphs…