mirror of https://github.com/aria2/aria2
2009-05-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Put a call to Socket::isReadable() in try block. * src/HttpServerBodyCommand.cc * src/HttpServerCommand.ccpull/1/head
parent
55c5cccf09
commit
64945c1f03
|
@ -1,3 +1,9 @@
|
||||||
|
2009-05-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Put a call to Socket::isReadable() in try block.
|
||||||
|
* src/HttpServerBodyCommand.cc
|
||||||
|
* src/HttpServerCommand.cc
|
||||||
|
|
||||||
2009-05-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-05-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Fixed segmentation fault error. SocketBuffer::sendResponse() may throw
|
Fixed segmentation fault error. SocketBuffer::sendResponse() may throw
|
||||||
|
|
|
@ -74,10 +74,10 @@ bool HttpServerBodyCommand::execute()
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(_socket->isReadable(0) || _httpServer->getContentLength() == 0) {
|
try {
|
||||||
_timeout.reset();
|
if(_socket->isReadable(0) || _httpServer->getContentLength() == 0) {
|
||||||
|
_timeout.reset();
|
||||||
|
|
||||||
try {
|
|
||||||
if(_httpServer->receiveBody()) {
|
if(_httpServer->receiveBody()) {
|
||||||
// Do something for requestpath and body
|
// Do something for requestpath and body
|
||||||
if(_httpServer->getRequestPath() == "/rpc") {
|
if(_httpServer->getRequestPath() == "/rpc") {
|
||||||
|
@ -101,20 +101,21 @@ bool HttpServerBodyCommand::execute()
|
||||||
_e->commands.push_back(this);
|
_e->commands.push_back(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch(RecoverableException& e) {
|
|
||||||
logger->info("CUID#%d - Error occurred while reading HTTP request body",
|
|
||||||
e, cuid);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(_timeout.elapsed(30)) {
|
|
||||||
logger->info("HTTP request body timeout.");
|
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
_e->commands.push_back(this);
|
if(_timeout.elapsed(30)) {
|
||||||
return false;
|
logger->info("HTTP request body timeout.");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_e->commands.push_back(this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch(RecoverableException& e) {
|
||||||
|
logger->info("CUID#%d - Error occurred while reading HTTP request body",
|
||||||
|
e, cuid);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -82,48 +82,50 @@ bool HttpServerCommand::execute()
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(_socket->isReadable(0)) {
|
try {
|
||||||
_timeout.reset();
|
if(_socket->isReadable(0)) {
|
||||||
SharedHandle<HttpHeader> header;
|
_timeout.reset();
|
||||||
try {
|
SharedHandle<HttpHeader> header;
|
||||||
|
|
||||||
header = _httpServer->receiveRequest();
|
header = _httpServer->receiveRequest();
|
||||||
} catch(RecoverableException& e) {
|
if(!_httpServer->authenticate()) {
|
||||||
logger->info("CUID#%d - Error occurred while reading HTTP request",
|
_httpServer->disableKeepAlive();
|
||||||
e, cuid);
|
_httpServer->feedResponse("401 Unauthorized",
|
||||||
return true;
|
"WWW-Authenticate: Basic realm=\"aria2\"",
|
||||||
}
|
"","text/html");
|
||||||
if(!_httpServer->authenticate()) {
|
Command* command =
|
||||||
_httpServer->disableKeepAlive();
|
new HttpServerResponseCommand(cuid, _httpServer, _e, _socket);
|
||||||
_httpServer->feedResponse("401 Unauthorized",
|
command->setStatus(Command::STATUS_ONESHOT_REALTIME);
|
||||||
"WWW-Authenticate: Basic realm=\"aria2\"",
|
_e->commands.push_back(command);
|
||||||
"","text/html");
|
_e->setNoWait(true);
|
||||||
Command* command =
|
return true;
|
||||||
new HttpServerResponseCommand(cuid, _httpServer, _e, _socket);
|
}
|
||||||
command->setStatus(Command::STATUS_ONESHOT_REALTIME);
|
if(header.isNull()) {
|
||||||
_e->commands.push_back(command);
|
_e->commands.push_back(this);
|
||||||
_e->setNoWait(true);
|
return false;
|
||||||
return true;
|
} else {
|
||||||
}
|
Command* command = new HttpServerBodyCommand(cuid, _httpServer, _e,
|
||||||
if(header.isNull()) {
|
_socket);
|
||||||
_e->commands.push_back(this);
|
command->setStatus(Command::STATUS_ONESHOT_REALTIME);
|
||||||
return false;
|
_e->commands.push_back(command);
|
||||||
|
_e->setNoWait(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Command* command = new HttpServerBodyCommand(cuid, _httpServer, _e,
|
if(_timeout.elapsed(30)) {
|
||||||
_socket);
|
logger->info("HTTP request timeout.");
|
||||||
command->setStatus(Command::STATUS_ONESHOT_REALTIME);
|
return true;
|
||||||
_e->commands.push_back(command);
|
} else {
|
||||||
_e->setNoWait(true);
|
_e->commands.push_back(this);
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if(_timeout.elapsed(30)) {
|
|
||||||
logger->info("HTTP request timeout.");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
_e->commands.push_back(this);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
} catch(RecoverableException& e) {
|
||||||
|
logger->info("CUID#%d - Error occurred while reading HTTP request",
|
||||||
|
e, cuid);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
Loading…
Reference in New Issue