| 107 | } |
| 108 | |
| 109 | void TEvhttpClientChannel::finish(struct evhttp_request* req) { |
| 110 | assert(!completionQueue_.empty()); |
| 111 | Completion completion = completionQueue_.front(); |
| 112 | completionQueue_.pop(); |
| 113 | if (req == nullptr) { |
| 114 | try { |
| 115 | completion.first(); |
| 116 | } catch (const TTransportException& e) { |
| 117 | if (e.getType() == TTransportException::END_OF_FILE) |
| 118 | throw TException("connect failed"); |
| 119 | else |
| 120 | throw; |
| 121 | } |
| 122 | return; |
| 123 | } else if (req->response_code != 200) { |
| 124 | try { |
| 125 | completion.first(); |
| 126 | } catch (const TTransportException& e) { |
| 127 | std::stringstream ss; |
| 128 | ss << "server returned code " << req->response_code; |
| 129 | if (req->response_code_line) |
| 130 | ss << ": " << req->response_code_line; |
| 131 | if (e.getType() == TTransportException::END_OF_FILE) |
| 132 | throw TException(ss.str()); |
| 133 | else |
| 134 | throw; |
| 135 | } |
| 136 | return; |
| 137 | } |
| 138 | completion.second->resetBuffer(EVBUFFER_DATA(req->input_buffer), |
| 139 | static_cast<uint32_t>(EVBUFFER_LENGTH(req->input_buffer))); |
| 140 | completion.first(); |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | /* static */ void TEvhttpClientChannel::response(struct evhttp_request* req, void* arg) { |
| 145 | auto* self = (TEvhttpClientChannel*)arg; |
no test coverage detected