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,6 +122,12 @@ createHttpRequest(const SharedHandle<Request>& req,
bool HttpRequestCommand::executeInternal() { bool HttpRequestCommand::executeInternal() {
//socket->setBlockingMode(); //socket->setBlockingMode();
if(httpConnection_->sendBufferIsEmpty()) {
if(!checkIfConnectionEstablished
(getSocket(), getRequest()->getConnectedHostname(),
getRequest()->getConnectedAddr(), getRequest()->getConnectedPort())) {
return true;
}
if(getRequest()->getProtocol() == "https") { if(getRequest()->getProtocol() == "https") {
if(!getSocket()->tlsConnect(getRequest()->getHost())) { if(!getSocket()->tlsConnect(getRequest()->getHost())) {
setReadCheckSocketIf(getSocket(), getSocket()->wantRead()); setReadCheckSocketIf(getSocket(), getSocket()->wantRead());
@ -130,13 +136,6 @@ bool HttpRequestCommand::executeInternal() {
return false; return false;
} }
} }
if(httpConnection_->sendBufferIsEmpty()) {
if(!checkIfConnectionEstablished
(getSocket(), getRequest()->getConnectedHostname(),
getRequest()->getConnectedAddr(), getRequest()->getConnectedPort())) {
return true;
}
if(getSegments().empty()) { if(getSegments().empty()) {
SharedHandle<HttpRequest> httpRequest SharedHandle<HttpRequest> httpRequest
(createHttpRequest(getRequest(), (createHttpRequest(getRequest(),