mirror of https://github.com/aria2/aria2
Check !SocketRecvBuffer::bufferEmpty() in ctor.
Also treat !SocketRecvBuffer::bufferEmpty() as data is available.pull/1/head
parent
e60181d1ad
commit
b2f27e6548
|
@ -116,6 +116,11 @@ public:
|
||||||
void disableGZip() { gzip_ = false; }
|
void disableGZip() { gzip_ = false; }
|
||||||
|
|
||||||
uint64_t getContentLength() const { return lastContentLength_; }
|
uint64_t getContentLength() const { return lastContentLength_; }
|
||||||
|
|
||||||
|
const SharedHandle<SocketRecvBuffer>& getSocketRecvBuffer() const
|
||||||
|
{
|
||||||
|
return socketRecvBuffer_;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
#include "SocketRecvBuffer.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -66,8 +67,12 @@ HttpServerBodyCommand::HttpServerBodyCommand
|
||||||
socket_(socket),
|
socket_(socket),
|
||||||
httpServer_(httpServer)
|
httpServer_(httpServer)
|
||||||
{
|
{
|
||||||
|
// To handle Content-Length == 0 case
|
||||||
setStatus(Command::STATUS_ONESHOT_REALTIME);
|
setStatus(Command::STATUS_ONESHOT_REALTIME);
|
||||||
e_->addSocketForReadCheck(socket_, this);
|
e_->addSocketForReadCheck(socket_, this);
|
||||||
|
if(!httpServer_->getSocketRecvBuffer()->bufferEmpty()) {
|
||||||
|
e_->setNoWait(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpServerBodyCommand::~HttpServerBodyCommand()
|
HttpServerBodyCommand::~HttpServerBodyCommand()
|
||||||
|
@ -81,7 +86,9 @@ bool HttpServerBodyCommand::execute()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if(socket_->isReadable(0) || httpServer_->getContentLength() == 0) {
|
if(socket_->isReadable(0) ||
|
||||||
|
!httpServer_->getSocketRecvBuffer()->bufferEmpty() ||
|
||||||
|
httpServer_->getContentLength() == 0) {
|
||||||
timeoutTimer_ = global::wallclock;
|
timeoutTimer_ = global::wallclock;
|
||||||
|
|
||||||
if(httpServer_->receiveBody()) {
|
if(httpServer_->receiveBody()) {
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
#include "SocketRecvBuffer.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -70,6 +71,7 @@ HttpServerCommand::HttpServerCommand
|
||||||
#else // !HAVE_LIBZ
|
#else // !HAVE_LIBZ
|
||||||
httpServer_->disableGZip();
|
httpServer_->disableGZip();
|
||||||
#endif // !HAVE_LIBZ
|
#endif // !HAVE_LIBZ
|
||||||
|
checkSocketRecvBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpServerCommand::HttpServerCommand
|
HttpServerCommand::HttpServerCommand
|
||||||
|
@ -83,6 +85,7 @@ HttpServerCommand::HttpServerCommand
|
||||||
httpServer_(httpServer)
|
httpServer_(httpServer)
|
||||||
{
|
{
|
||||||
e_->addSocketForReadCheck(socket_, this);
|
e_->addSocketForReadCheck(socket_, this);
|
||||||
|
checkSocketRecvBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpServerCommand::~HttpServerCommand()
|
HttpServerCommand::~HttpServerCommand()
|
||||||
|
@ -90,13 +93,22 @@ HttpServerCommand::~HttpServerCommand()
|
||||||
e_->deleteSocketForReadCheck(socket_, this);
|
e_->deleteSocketForReadCheck(socket_, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HttpServerCommand::checkSocketRecvBuffer()
|
||||||
|
{
|
||||||
|
if(!httpServer_->getSocketRecvBuffer()->bufferEmpty()) {
|
||||||
|
setStatus(Command::STATUS_ONESHOT_REALTIME);
|
||||||
|
e_->setNoWait(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool HttpServerCommand::execute()
|
bool HttpServerCommand::execute()
|
||||||
{
|
{
|
||||||
if(e_->getRequestGroupMan()->downloadFinished() || e_->isHaltRequested()) {
|
if(e_->getRequestGroupMan()->downloadFinished() || e_->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if(socket_->isReadable(0)) {
|
if(socket_->isReadable(0) ||
|
||||||
|
!httpServer_->getSocketRecvBuffer()->bufferEmpty()) {
|
||||||
timeoutTimer_ = global::wallclock;
|
timeoutTimer_ = global::wallclock;
|
||||||
SharedHandle<HttpHeader> header;
|
SharedHandle<HttpHeader> header;
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,8 @@ private:
|
||||||
SharedHandle<SocketCore> socket_;
|
SharedHandle<SocketCore> socket_;
|
||||||
SharedHandle<HttpServer> httpServer_;
|
SharedHandle<HttpServer> httpServer_;
|
||||||
Timer timeoutTimer_;
|
Timer timeoutTimer_;
|
||||||
|
|
||||||
|
void checkSocketRecvBuffer();
|
||||||
public:
|
public:
|
||||||
HttpServerCommand(cuid_t cuid, DownloadEngine* e,
|
HttpServerCommand(cuid_t cuid, DownloadEngine* e,
|
||||||
const SharedHandle<SocketCore>& socket);
|
const SharedHandle<SocketCore>& socket);
|
||||||
|
|
Loading…
Reference in New Issue