mirror of https://github.com/aria2/aria2
HttpServer: Use std::unique_ptr for lastBody_ and headerProcessor_
parent
fba7e7ee8b
commit
d2ec57057e
|
@ -61,7 +61,7 @@ HttpServer::HttpServer(const std::shared_ptr<SocketCore>& socket)
|
||||||
: socket_(socket),
|
: socket_(socket),
|
||||||
socketRecvBuffer_(new SocketRecvBuffer(socket_)),
|
socketRecvBuffer_(new SocketRecvBuffer(socket_)),
|
||||||
socketBuffer_(socket),
|
socketBuffer_(socket),
|
||||||
headerProcessor_(new HttpHeaderProcessor
|
headerProcessor_(make_unique<HttpHeaderProcessor>
|
||||||
(HttpHeaderProcessor::SERVER_PARSER)),
|
(HttpHeaderProcessor::SERVER_PARSER)),
|
||||||
lastContentLength_(0),
|
lastContentLength_(0),
|
||||||
bodyConsumed_(0),
|
bodyConsumed_(0),
|
||||||
|
@ -382,6 +382,11 @@ std::string HttpServer::createQuery() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DiskWriter* HttpServer::getBody() const
|
||||||
|
{
|
||||||
|
return lastBody_.get();
|
||||||
|
}
|
||||||
|
|
||||||
bool HttpServer::supportsPersistentConnection() const
|
bool HttpServer::supportsPersistentConnection() const
|
||||||
{
|
{
|
||||||
return keepAlive_ &&
|
return keepAlive_ &&
|
||||||
|
|
|
@ -67,14 +67,14 @@ private:
|
||||||
std::shared_ptr<SocketCore> socket_;
|
std::shared_ptr<SocketCore> socket_;
|
||||||
std::shared_ptr<SocketRecvBuffer> socketRecvBuffer_;
|
std::shared_ptr<SocketRecvBuffer> socketRecvBuffer_;
|
||||||
SocketBuffer socketBuffer_;
|
SocketBuffer socketBuffer_;
|
||||||
std::shared_ptr<HttpHeaderProcessor> headerProcessor_;
|
std::unique_ptr<HttpHeaderProcessor> headerProcessor_;
|
||||||
std::shared_ptr<HttpHeader> lastRequestHeader_;
|
std::shared_ptr<HttpHeader> lastRequestHeader_;
|
||||||
int64_t lastContentLength_;
|
int64_t lastContentLength_;
|
||||||
// How many bytes are consumed. The total number of bytes is
|
// How many bytes are consumed. The total number of bytes is
|
||||||
// lastContentLength_.
|
// lastContentLength_.
|
||||||
int64_t bodyConsumed_;
|
int64_t bodyConsumed_;
|
||||||
RequestType reqType_;
|
RequestType reqType_;
|
||||||
std::shared_ptr<DiskWriter> lastBody_;
|
std::unique_ptr<DiskWriter> lastBody_;
|
||||||
bool keepAlive_;
|
bool keepAlive_;
|
||||||
bool gzip_;
|
bool gzip_;
|
||||||
std::string username_;
|
std::string username_;
|
||||||
|
@ -101,10 +101,7 @@ public:
|
||||||
|
|
||||||
std::string createQuery() const;
|
std::string createQuery() const;
|
||||||
|
|
||||||
const std::shared_ptr<DiskWriter>& getBody() const
|
DiskWriter* getBody() const;
|
||||||
{
|
|
||||||
return lastBody_;
|
|
||||||
}
|
|
||||||
|
|
||||||
RequestType getRequestType() const
|
RequestType getRequestType() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -210,7 +210,7 @@ bool HttpServerBodyCommand::execute()
|
||||||
switch(httpServer_->getRequestType()) {
|
switch(httpServer_->getRequestType()) {
|
||||||
case RPC_TYPE_XML: {
|
case RPC_TYPE_XML: {
|
||||||
#ifdef ENABLE_XML_RPC
|
#ifdef ENABLE_XML_RPC
|
||||||
auto dw = std::static_pointer_cast<rpc::XmlRpcDiskWriter>
|
auto dw = static_cast<rpc::XmlRpcDiskWriter*>
|
||||||
(httpServer_->getBody());
|
(httpServer_->getBody());
|
||||||
int error;
|
int error;
|
||||||
error = dw->finalize();
|
error = dw->finalize();
|
||||||
|
@ -255,7 +255,7 @@ bool HttpServerBodyCommand::execute()
|
||||||
param.request.size(),
|
param.request.size(),
|
||||||
error);
|
error);
|
||||||
} else {
|
} else {
|
||||||
auto dw = std::static_pointer_cast<json::JsonDiskWriter>
|
auto dw = static_cast<json::JsonDiskWriter*>
|
||||||
(httpServer_->getBody());
|
(httpServer_->getBody());
|
||||||
error = dw->finalize();
|
error = dw->finalize();
|
||||||
if(error == 0) {
|
if(error == 0) {
|
||||||
|
|
Loading…
Reference in New Issue