| 248 | } |
| 249 | |
| 250 | bool http_request::write_head() |
| 251 | { |
| 252 | bool reuse_conn; |
| 253 | http_method_t method = header_.get_method(); |
| 254 | |
| 255 | while (true) { |
| 256 | // ���Դ�Զ������ |
| 257 | if (! try_open(&reuse_conn)) { |
| 258 | logger_error("connect server error"); |
| 259 | need_retry_ = false; |
| 260 | return false; |
| 261 | |
| 262 | } |
| 263 | |
| 264 | // ������´��������ӣ��������� |
| 265 | if (!reuse_conn) { |
| 266 | need_retry_ = false; |
| 267 | } |
| 268 | |
| 269 | // ��������� GET/PURGE/HEAD/DELETE/CONNECT�� |
| 270 | // ����Ҫ����̽��һ�������Ƿ����� |
| 271 | if (method != HTTP_METHOD_GET |
| 272 | && method != HTTP_METHOD_PURGE |
| 273 | && method != HTTP_METHOD_HEAD |
| 274 | && method != HTTP_METHOD_DELETE |
| 275 | && method != HTTP_METHOD_OPTION |
| 276 | && method != HTTP_METHOD_CONNECT |
| 277 | && !client_->get_stream().alive()) { |
| 278 | |
| 279 | /* ��Ϊϵͳ write API �ɹ������ܱ�֤��������������ֻ�� |
| 280 | * �ǵ���ϵͳ read API ��̽�������Ƿ��������ú����ڲ� |
| 281 | * �Ὣ�ӿ���ת�������ӿڽ��ж����������Բ��������� |
| 282 | * ͬʱ��ʹ�����ݶ���Ҳ���ȷŵ� ACL_VSTREAM �������У� |
| 283 | * ����Ҳ���ᶪʧ���� |
| 284 | */ |
| 285 | close(); |
| 286 | |
| 287 | // �����´��������ӣ���ֱ�ӱ��� |
| 288 | if (!reuse_conn) { |
| 289 | logger_error("new connection error"); |
| 290 | return false; |
| 291 | } |
| 292 | |
| 293 | need_retry_ = false; |
| 294 | continue; |
| 295 | } |
| 296 | |
| 297 | client_->reset(); // ����״̬ |
| 298 | |
| 299 | // ���� HTTP ����ͷ |
| 300 | if (client_->write_head(header_)) { |
| 301 | return true; |
| 302 | } |
| 303 | |
| 304 | close(); |
| 305 | |
| 306 | if (!need_retry_) { |
| 307 | return false; |
no test coverage detected