| 1235 | } |
| 1236 | |
| 1237 | void DoRun(TCont* c) override { |
| 1238 | THolder<THttpsRequest> This(this); |
| 1239 | |
| 1240 | if (c->Cancelled()) { |
| 1241 | Hndl_->NotifyError(new TError("canceled", TError::TType::Cancelled)); |
| 1242 | return; |
| 1243 | } |
| 1244 | |
| 1245 | TErrorRef error; |
| 1246 | TConnCache::TConnectionRef connection(ConnectionCache()->Connect(c, Msg_.Addr, *Addr_, &error)); |
| 1247 | if (!connection) { |
| 1248 | Hndl_->NotifyError(error); |
| 1249 | return; |
| 1250 | } |
| 1251 | |
| 1252 | TSslClientIOStream io(TSslCtxClient::Instance(), Loc_, (*connection)->Fd(), Hndl_->CanceledPtr()); |
| 1253 | TContBIOWatcher w(io, c); |
| 1254 | TString received; |
| 1255 | THttpHeaders headers; |
| 1256 | TString firstLine; |
| 1257 | |
| 1258 | try { |
| 1259 | if ((*connection)->HasSsl()) { |
| 1260 | io.SetSsl((*connection)->MoveSsl()); |
| 1261 | } else { |
| 1262 | io.Handshake(); |
| 1263 | } |
| 1264 | RequestData().SendTo(io); |
| 1265 | Req_.Destroy(); |
| 1266 | error = ProcessRecv(io, &received, &headers, &firstLine); |
| 1267 | (*connection)->SetSsl(io.MoveSsl()); |
| 1268 | (*connection)->ResetBIO(); |
| 1269 | } catch (const TSystemError& e) { |
| 1270 | if (c->Cancelled() || e.Status() == ECANCELED) { |
| 1271 | error = new TError("canceled", TError::TType::Cancelled); |
| 1272 | } else { |
| 1273 | error = new TError(CurrentExceptionMessage()); |
| 1274 | } |
| 1275 | } catch (...) { |
| 1276 | if (c->Cancelled()) { |
| 1277 | error = new TError("canceled", TError::TType::Cancelled); |
| 1278 | } else { |
| 1279 | error = new TError(CurrentExceptionMessage()); |
| 1280 | } |
| 1281 | } |
| 1282 | |
| 1283 | if (error) { |
| 1284 | Hndl_->NotifyError(error, received, firstLine, headers); |
| 1285 | } else { |
| 1286 | ConnectionCache()->Release(connection); |
| 1287 | Hndl_->NotifyResponse(received, firstLine, headers); |
| 1288 | } |
| 1289 | } |
| 1290 | |
| 1291 | TErrorRef ProcessRecv(TSslClientIOStream& io, TString* data, THttpHeaders* headers, TString* firstLine) { |
| 1292 | io.WaitUntilWritten(); |
nothing calls this directly
no test coverage detected