Perform SSL/TLS handshake after checking whether connection is established

pull/28/head
Tatsuhiro Tsujikawa 2012-10-15 23:26:51 +09:00
parent c904aa50fe
commit 841395f332
1 changed files with 8 additions and 9 deletions

View File

@ -122,21 +122,20 @@ createHttpRequest(const SharedHandle<Request>& req,
bool HttpRequestCommand::executeInternal() {
//socket->setBlockingMode();
if(getRequest()->getProtocol() == "https") {
if(!getSocket()->tlsConnect(getRequest()->getHost())) {
setReadCheckSocketIf(getSocket(), getSocket()->wantRead());
setWriteCheckSocketIf(getSocket(), getSocket()->wantWrite());
getDownloadEngine()->addCommand(this);
return false;
}
}
if(httpConnection_->sendBufferIsEmpty()) {
if(!checkIfConnectionEstablished
(getSocket(), getRequest()->getConnectedHostname(),
getRequest()->getConnectedAddr(), getRequest()->getConnectedPort())) {
return true;
}
if(getRequest()->getProtocol() == "https") {
if(!getSocket()->tlsConnect(getRequest()->getHost())) {
setReadCheckSocketIf(getSocket(), getSocket()->wantRead());
setWriteCheckSocketIf(getSocket(), getSocket()->wantWrite());
getDownloadEngine()->addCommand(this);
return false;
}
}
if(getSegments().empty()) {
SharedHandle<HttpRequest> httpRequest
(createHttpRequest(getRequest(),