���� ipc_request ���Զ����ô˻ص������������ @override
| 96 | // ���� ipc_request ���Զ����ô˻ص������������ |
| 97 | // @override |
| 98 | void run(ipc_client* ipc) |
| 99 | { |
| 100 | unsigned int nredirect_limit = data_.callback->get_redirect(); |
| 101 | unsigned int nredirect = 0; |
| 102 | http_status_t ret; |
| 103 | |
| 104 | while (true) { |
| 105 | if ((ret = connect_server()) != HTTP_OK) { |
| 106 | report_error(ipc, ret); |
| 107 | break; |
| 108 | } |
| 109 | if ((ret = send_request()) != HTTP_OK) { |
| 110 | report_error(ipc, ret); |
| 111 | break; |
| 112 | } |
| 113 | if ((ret = read_respond_hdr()) != HTTP_OK) { |
| 114 | report_error(ipc, ret); |
| 115 | break; |
| 116 | } |
| 117 | |
| 118 | acl_assert(hdr_res_); |
| 119 | |
| 120 | // ������������ص����ض�����Ϣ��������ض������ |
| 121 | |
| 122 | if ((hdr_res_->reply_status != 301 |
| 123 | && hdr_res_->reply_status != 302) |
| 124 | || nredirect_limit == 0) { |
| 125 | |
| 126 | // ������Ӧͷ�յ���Ϣ�����߳� |
| 127 | report(ipc, HTTP_MSG_HDR); |
| 128 | |
| 129 | // ����������Ӧ�岢����Ӧ���յ���Ϣ�����߳� |
| 130 | read_respond_body(ipc); |
| 131 | break; |
| 132 | } |
| 133 | |
| 134 | // ��ʼ�ض������ |
| 135 | |
| 136 | nredirect++; |
| 137 | // ��ֹ�ض������̫��������ѭ�� |
| 138 | if (nredirect > nredirect_limit) { |
| 139 | report_error(ipc, HTTP_ERR_REDIRECT_MAX); |
| 140 | break; |
| 141 | } |
| 142 | |
| 143 | const char* url = http_hdr_entry_value( |
| 144 | &hdr_res_->hdr, "Location"); |
| 145 | |
| 146 | if (url == NULL) { |
| 147 | logger_error("redirect Location null"); |
| 148 | report_error(ipc, HTTP_ERR_INVALID_HDR); |
| 149 | break; |
| 150 | } |
| 151 | if (!data_.callback->redirect(url)) { |
| 152 | http_hdr_res_free(hdr_res_); |
| 153 | hdr_res_ = NULL; |
| 154 | report_error(ipc, HTTP_ERR_INVALID_HDR); |
| 155 | break; |
nothing calls this directly
no test coverage detected