| 542 | |
| 543 | |
| 544 | StreamSocket HTTPClientSession::proxyConnect() |
| 545 | { |
| 546 | URI proxyUri; |
| 547 | proxyUri.setScheme(getProxyProtocol()); |
| 548 | proxyUri.setHost(getProxyHost()); |
| 549 | proxyUri.setPort(getProxyPort()); |
| 550 | |
| 551 | SharedPtr<HTTPClientSession> proxySession (_proxySessionFactory.createClientSession(proxyUri)); |
| 552 | |
| 553 | proxySession->setTimeout(getTimeout()); |
| 554 | std::string targetAddress(_host); |
| 555 | targetAddress.append(":"); |
| 556 | NumberFormatter::append(targetAddress, _port); |
| 557 | HTTPRequest proxyRequest(HTTPRequest::HTTP_CONNECT, targetAddress, HTTPMessage::HTTP_1_1); |
| 558 | HTTPResponse proxyResponse; |
| 559 | proxyRequest.set("Proxy-Connection", "keep-alive"); |
| 560 | proxyRequest.set("Host", targetAddress); |
| 561 | proxyAuthenticateImpl(proxyRequest); |
| 562 | proxySession->setKeepAlive(true); |
| 563 | proxySession->sendRequest(proxyRequest); |
| 564 | proxySession->receiveResponse(proxyResponse); |
| 565 | if (proxyResponse.getStatus() != HTTPResponse::HTTP_OK) |
| 566 | throw HTTPException("Cannot establish proxy connection", proxyResponse.getReason()); |
| 567 | return proxySession->detachSocket(); |
| 568 | } |
| 569 | |
| 570 | |
| 571 | void HTTPClientSession::proxyTunnel() |
nothing calls this directly
no test coverage detected