| 494 | if (not result) |
| 495 | { |
| 496 | fail(result); |
| 497 | } |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | Result HttpAsyncClient::beginExternalConnection() |
| 502 | { |
| 503 | state = State::Connecting; |
| 504 | |
| 505 | HttpAsyncClientExternalConnection externalConnection; |
| 506 | externalConnection.connection = connection; |
| 507 | externalConnection.eventLoop = eventLoop; |
| 508 | externalConnection.url = ¤tURL; |
| 509 | externalConnection.complete = {[this](Result result) { completeTransportSetup(result); }}; |
| 510 | externalConnection.fail = {[this](Result result) { fail(result); }}; |
| 511 | |
| 512 | Result result = externalConnector(externalConnection); |
| 513 | if (not result) |
| 514 | { |
| 515 | response.abortBodyStream(); |
| 516 | closeConnection(); |
| 517 | state = State::Idle; |
| 518 | currentRequest = nullptr; |
| 519 | request.reset(); |
| 520 | } |
| 521 | return result; |
| 522 | } |
| 523 | |
| 524 | Result HttpAsyncClient::beginSocketConnection() |
| 525 | { |
| 526 | char addressBuffer[256]; |
| 527 | Span<char> ipAddress = {addressBuffer}; |
| 528 | SC_TRY(SocketDNS::resolveDNS(currentURL.hostname, ipAddress)); |
| 529 | |
| 530 | SocketIPAddress remoteAddress; |
| 531 | SC_TRY(remoteAddress.fromAddressPort({ipAddress, true, StringEncoding::Ascii}, currentURL.port)); |
| 532 | SC_TRY(eventLoop->createAsyncTCPSocket(remoteAddress.getAddressFamily(), connection->socket)); |
| 533 | |
| 534 | state = State::Connecting; |
| 535 | return connectAsync.start(*eventLoop, connection->socket, remoteAddress); |
| 536 | } |
| 537 | |
| 538 | void HttpAsyncClient::onConnected(AsyncSocketConnect::Result& result) |
| 539 | { |
| 540 | if (not result.isValid()) |
| 541 | { |
nothing calls this directly
no test coverage detected